-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
936f886
commit 8146091
Showing
30 changed files
with
203 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
Dfe.Academies.Academisation.Data.UnitTest/Http/AcademiesApiClientFactoryFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 59 additions & 59 deletions
118
Dfe.Academies.Academisation.Data.UnitTest/ProjectAggregate/ProjectNoteDeleteCommandTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AutoFixture; | ||
using Dfe.Academies.Academisation.Core; | ||
using Dfe.Academies.Academisation.Data.ProjectAggregate; | ||
using Dfe.Academies.Academisation.Data.UnitTest.Contexts; | ||
using Dfe.Academies.Academisation.Domain.Core.ProjectAggregate; | ||
using Dfe.Academies.Academisation.Domain.ProjectAggregate; | ||
using Dfe.Academies.Academisation.IDomain.ProjectAggregate; | ||
using FluentAssertions; | ||
using Xunit; | ||
//using System; | ||
//using System.Collections.Generic; | ||
//using System.Linq; | ||
//using System.Threading.Tasks; | ||
//using AutoFixture; | ||
//using Dfe.Academies.Academisation.Core; | ||
//using Dfe.Academies.Academisation.Data.ProjectAggregate; | ||
//using Dfe.Academies.Academisation.Data.UnitTest.Contexts; | ||
//using Dfe.Academies.Academisation.Domain.Core.ProjectAggregate; | ||
//using Dfe.Academies.Academisation.Domain.ProjectAggregate; | ||
//using Dfe.Academies.Academisation.IDomain.ProjectAggregate; | ||
//using FluentAssertions; | ||
//using Xunit; | ||
|
||
namespace Dfe.Academies.Academisation.Data.UnitTest.ProjectAggregate | ||
{ | ||
public class ProjectNoteDeleteCommandTests | ||
{ | ||
private readonly AcademisationContext _context; | ||
private readonly Fixture _fixture; | ||
private readonly IList<ProjectNote> _notes; | ||
//namespace Dfe.Academies.Academisation.Data.UnitTest.ProjectAggregate | ||
//{ | ||
// public class ProjectNoteDeleteCommandTests | ||
// { | ||
// private readonly AcademisationContext _context; | ||
// private readonly Fixture _fixture; | ||
// private readonly IList<ProjectNote> _notes; | ||
|
||
public ProjectNoteDeleteCommandTests() | ||
{ | ||
var testProjectContext = new TestProjectContext(); | ||
_context = testProjectContext.CreateContext(); | ||
// public ProjectNoteDeleteCommandTests() | ||
// { | ||
// var testProjectContext = new TestProjectContext(); | ||
// _context = testProjectContext.CreateContext(); | ||
|
||
_fixture = new Fixture(); | ||
// _fixture = new Fixture(); | ||
|
||
IList<Project> projects = _fixture.CreateMany<Project>(3).ToList(); | ||
// IList<Project> projects = _fixture.CreateMany<Project>(3).ToList(); | ||
|
||
_notes = _fixture.CreateMany<ProjectNote>().ToList(); | ||
// _notes = _fixture.CreateMany<ProjectNote>().ToList(); | ||
|
||
_notes = _notes.Select(x => new ProjectNote(x.Subject, x.Note, x.Author, x.Date, projects[Random.Shared.Next(projects.Count)].Id)) | ||
.ToList(); | ||
// _notes = _notes.Select(x => new ProjectNote(x.Subject, x.Note, x.Author, x.Date, projects[Random.Shared.Next(projects.Count)].Id)) | ||
// .ToList(); | ||
|
||
_context.Projects.AddRangeAsync(projects); | ||
_context.ProjectNotes.AddRangeAsync(_notes); | ||
_context.SaveChanges(); | ||
} | ||
// _context.Projects.AddRangeAsync(projects); | ||
// _context.ProjectNotes.AddRangeAsync(_notes); | ||
// _context.SaveChanges(); | ||
// } | ||
|
||
private ProjectNote RandomNote => _notes[Random.Shared.Next(_notes.Count)]; | ||
// private ProjectNote RandomNote => _notes[Random.Shared.Next(_notes.Count)]; | ||
|
||
private ProjectNoteDeleteCommand System_under_test() | ||
{ | ||
return new ProjectNoteDeleteCommand(_context); | ||
} | ||
// private ProjectNoteDeleteCommand System_under_test() | ||
// { | ||
// return new ProjectNoteDeleteCommand(_context); | ||
// } | ||
|
||
[Fact] | ||
public async Task Should_return_not_found_result_if_the_note_does_not_exist() | ||
{ | ||
ProjectNote noteToDelete = _fixture.Create<ProjectNote>(); | ||
// [Fact] | ||
// public async Task Should_return_not_found_result_if_the_note_does_not_exist() | ||
// { | ||
// ProjectNote noteToDelete = _fixture.Create<ProjectNote>(); | ||
|
||
ProjectNoteDeleteCommand command = System_under_test(); | ||
// ProjectNoteDeleteCommand command = System_under_test(); | ||
|
||
_context.ProjectNotes.Should().NotContain(noteToDelete); | ||
// _context.ProjectNotes.Should().NotContain(noteToDelete); | ||
|
||
CommandResult result = await command.Execute(noteToDelete.ProjectId, noteToDelete); | ||
// CommandResult result = await command.Execute(noteToDelete.ProjectId, noteToDelete); | ||
|
||
result.Should().BeOfType<NotFoundCommandResult>(); | ||
} | ||
// result.Should().BeOfType<NotFoundCommandResult>(); | ||
// } | ||
|
||
[Fact] | ||
public async Task Should_remove_the_note() | ||
{ | ||
ProjectNote noteToDelete = RandomNote; | ||
// [Fact] | ||
// public async Task Should_remove_the_note() | ||
// { | ||
// ProjectNote noteToDelete = RandomNote; | ||
|
||
ProjectNoteDeleteCommand command = System_under_test(); | ||
// ProjectNoteDeleteCommand command = System_under_test(); | ||
|
||
_context.ProjectNotes.Should().Contain(noteToDelete); | ||
// _context.ProjectNotes.Should().Contain(noteToDelete); | ||
|
||
CommandResult result = await command.Execute(noteToDelete.ProjectId, noteToDelete); | ||
// CommandResult result = await command.Execute(noteToDelete.ProjectId, noteToDelete); | ||
|
||
result.Should().BeOfType<CommandSuccessResult>(); | ||
// result.Should().BeOfType<CommandSuccessResult>(); | ||
|
||
_context.ProjectNotes.Should().NotContain(noteToDelete); | ||
} | ||
} | ||
} | ||
// _context.ProjectNotes.Should().NotContain(noteToDelete); | ||
// } | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
Dfe.Academies.Academisation.Data/Http/AcademiesApiClientFactoryFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
....IData/Http/IAcademiesApiClientFactory.cs → ...n.Data/Http/IAcademiesApiClientFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Dfe.Academies.Academisation.Data/ProjectAggregate/IProjectUpdateDataCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Dfe.Academies.Academisation.IDomain.ProjectAggregate; | ||
|
||
namespace Dfe.Academies.Academisation.Data.ProjectAggregate; | ||
|
||
public interface IProjectUpdateDataCommand | ||
{ | ||
Task Execute(IProject project); | ||
} |
64 changes: 32 additions & 32 deletions
64
Dfe.Academies.Academisation.Data/ProjectAggregate/ProjectNoteDeleteCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
using Dfe.Academies.Academisation.Core; | ||
using Dfe.Academies.Academisation.Domain.Core.ProjectAggregate; | ||
using Dfe.Academies.Academisation.IData.ProjectAggregate; | ||
using Microsoft.EntityFrameworkCore; | ||
//using Dfe.Academies.Academisation.Core; | ||
//using Dfe.Academies.Academisation.Domain.Core.ProjectAggregate; | ||
//using Dfe.Academies.Academisation.IData.ProjectAggregate; | ||
//using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Dfe.Academies.Academisation.Data.ProjectAggregate | ||
{ | ||
public class ProjectNoteDeleteCommand : IProjectNoteDeleteCommand | ||
{ | ||
private readonly AcademisationContext _context; | ||
//namespace Dfe.Academies.Academisation.Data.ProjectAggregate | ||
//{ | ||
// public class ProjectNoteDeleteCommand : IProjectNoteDeleteCommand | ||
// { | ||
// private readonly AcademisationContext _context; | ||
|
||
public ProjectNoteDeleteCommand(AcademisationContext context) | ||
{ | ||
_context = context; | ||
} | ||
// public ProjectNoteDeleteCommand(AcademisationContext context) | ||
// { | ||
// _context = context; | ||
// } | ||
|
||
public async Task<CommandResult> Execute(int projectId, ProjectNote note) | ||
{ | ||
ProjectNote? matchedNote = | ||
await _context.ProjectNotes | ||
.FirstOrDefaultAsync(x => x.ProjectId == projectId && | ||
x.Subject == note.Subject && | ||
x.Note == note.Note && | ||
x.Author == note.Author && | ||
x.Date == note.Date); | ||
// public async Task<CommandResult> Execute(int projectId, ProjectNote note) | ||
// { | ||
// ProjectNote? matchedNote = | ||
// await _context.ProjectNotes | ||
// .FirstOrDefaultAsync(x => x.ProjectId == projectId && | ||
// x.Subject == note.Subject && | ||
// x.Note == note.Note && | ||
// x.Author == note.Author && | ||
// x.Date == note.Date); | ||
|
||
if (matchedNote is null) | ||
{ | ||
return new NotFoundCommandResult(); | ||
} | ||
// if (matchedNote is null) | ||
// { | ||
// return new NotFoundCommandResult(); | ||
// } | ||
|
||
_context.ProjectNotes.Remove(matchedNote); | ||
await _context.SaveChangesAsync(); | ||
// _context.ProjectNotes.Remove(matchedNote); | ||
// await _context.SaveChangesAsync(); | ||
|
||
return new CommandSuccessResult(); | ||
} | ||
} | ||
} | ||
// return new CommandSuccessResult(); | ||
// } | ||
// } | ||
//} |
1 change: 0 additions & 1 deletion
1
Dfe.Academies.Academisation.Data/ProjectAggregate/ProjectUpdateDataCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
Dfe.Academies.Academisation.IData/ProjectAggregate/IProjectNoteDeleteCommand.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...emies.Academisation.Service.UnitTest/Commands/Legacy/Project/EnrichProjectCommandTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.