public async Task Then_The_Standards_Are_Filtered_By_Level( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockCoursesDbContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); mockCoursesDbContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var actual = await repository.GetStandards( new List <int>(), new List <int> { activeValidStandards[0].Level }, StandardFilter.ActiveAvailable); actual.Should().BeEquivalentTo(new List <Standard> { activeValidStandards[0] }); }
public async Task Then_Active_Standards_Are_Returned_Including_Not_Available_To_Start_When_Filter_Set_To_Active( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockDbContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); mockDbContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var actualStandards = await repository.GetStandards(new List <int>(), new List <int>(), StandardFilter.Active); Assert.IsNotNull(actualStandards); var expectedList = new List <Standard>(); expectedList.AddRange(activeValidStandards); expectedList.AddRange(activeInvalidStandards); expectedList.AddRange(retiredStandards); actualStandards.Should().BeEquivalentTo(expectedList); }
public async Task Then_Gets_Count_From_Context_Of_All_Standards( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockDataContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); mockDataContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var count = await repository.Count(StandardFilter.None); var total = activeInvalidStandards.Count + activeInvalidStandards.Count + notYetApprovedStandards.Count + withdrawnStandards.Count + retiredStandards.Count; count.Should().Be(total); }
public async Task And_Standard_Not_Valid_And_Does_Match_Route_Filter_Then_Standard_Not_Returned( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockCoursesDbContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); mockCoursesDbContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); //Act var actual = await repository.GetStandards( new List <int> { activeInvalidStandards[0].RouteCode }, new List <int>(), StandardFilter.ActiveAvailable); //Assert Assert.IsNotNull(actual); actual.Should().BeEquivalentTo(new List <Standard>()); }
public void Arrange() { // same standard with lars code, on retired and two active _standards = new List <Standard> { new Standard() { IfateReferenceNumber = "ST001", StandardUId = "ST001_1.0", LarsCode = 1, Status = "Approved for delivery", Version = 1.0m, LarsStandard = new LarsStandard { LarsCode = 1 } }, new Standard { IfateReferenceNumber = "ST002", StandardUId = "ST002_1.1", LarsCode = 2, Status = "Approved for delivery", Version = 1.1m, LarsStandard = new LarsStandard { LarsCode = 2 } }, new Standard { IfateReferenceNumber = "ST002", StandardUId = ExpectedStandardUId, LarsCode = 2, Status = "Approved for delivery", Version = 1.2m, LarsStandard = new LarsStandard { LarsCode = 2 } }, new Standard { IfateReferenceNumber = "ST002", StandardUId = "ST002_1.0", LarsCode = 2, Status = "Retired", Version = 1.0m, LarsStandard = new LarsStandard { LarsCode = 2 } } }; _coursesDataContext = new Mock <ICoursesDataContext>(); _coursesDataContext.Setup(x => x.Standards).ReturnsDbSet(_standards); _standardRepository = new Data.Repository.StandardRepository(_coursesDataContext.Object); }
public async Task Then_Active_Standards_Are_Returned_Including_Retired_With_Distinct_LarsCode( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockDbContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); //set up active version var newActiveVersion = activeValidStandards.First(); newActiveVersion.IfateReferenceNumber = "ST0001"; newActiveVersion.Version = 2; newActiveVersion.LarsCode = 100002; //add a retired version to have same IfateReferenceNumber and different LarsCode var retiredStandardWithDistinctLarsCode = activeValidStandards.Select(x => new Standard { IfateReferenceNumber = x.IfateReferenceNumber, Status = "Retired", LarsCode = 100001, Version = 1, LarsStandard = newActiveVersion.LarsStandard }).First(); allStandards.Add(retiredStandardWithDistinctLarsCode); mockDbContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var actualStandards = await repository.GetStandards(new List <int>(), new List <int>(), StandardFilter.Active); Assert.IsNotNull(actualStandards); var expectedList = new List <Standard>(); expectedList.AddRange(activeValidStandards); expectedList.AddRange(activeInvalidStandards); expectedList.AddRange(retiredStandards); expectedList.Add(retiredStandardWithDistinctLarsCode); actualStandards.Should().BeEquivalentTo(expectedList); }
public void Arrange() { _standards = new List <Standard> { new Standard() { StandardUId = "unknown" }, new Standard { StandardUId = ExpectedStandardUId } }; _coursesDataContext = new Mock <ICoursesDataContext>(); _coursesDataContext.Setup(x => x.Standards).ReturnsDbSet(_standards); _standardRepository = new Data.Repository.StandardRepository(_coursesDataContext.Object); }
public void Arrange() { _standards = new List <Standard> { new Standard() { LarsCode = 1 }, new Standard { LarsCode = 2 } }; _coursesDataContext = new Mock <ICoursesDataContext>(); _coursesDataContext.Setup(x => x.Standards).ReturnsDbSet(_standards); _standardRepository = new Data.Repository.StandardRepository(_coursesDataContext.Object); }
public async Task Then_All_Versions_Of_That_Standard_Are_Returned( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockDbContext, Data.Repository.StandardRepository repository) { var iFateReferenceNumber = "ST001"; var active = activeValidStandards[0]; active.IfateReferenceNumber = iFateReferenceNumber; active.Version = 1.1m; active.StandardUId = "ST001_1.1"; var retired = retiredStandards[0]; retired.IfateReferenceNumber = iFateReferenceNumber; retired.Version = 1.0m; retired.StandardUId = "ST001_1.0"; var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); mockDbContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var actualStandards = await repository.GetStandards(iFateReferenceNumber); Assert.IsNotNull(actualStandards); actualStandards.Should().BeEquivalentTo(new List <Standard> { active, retired }); }
public async Task Then_Gets_Count_From_Context_Of_Active_Standards_Including_Retired_With_Distinct_LarsCode( [StandardsAreLarsValid] List <Standard> activeValidStandards, [StandardsNotLarsValid] List <Standard> activeInvalidStandards, [StandardsNotYetApproved] List <Standard> notYetApprovedStandards, [StandardsWithdrawn] List <Standard> withdrawnStandards, [StandardsRetired] List <Standard> retiredStandards, [Frozen] Mock <ICoursesDataContext> mockDataContext, Data.Repository.StandardRepository repository) { var allStandards = new List <Standard>(); allStandards.AddRange(activeValidStandards); allStandards.AddRange(activeInvalidStandards); allStandards.AddRange(notYetApprovedStandards); allStandards.AddRange(withdrawnStandards); allStandards.AddRange(retiredStandards); //set up active version var newActiveVersion = activeValidStandards.First(); newActiveVersion.IfateReferenceNumber = "ST0001"; newActiveVersion.Version = 2; newActiveVersion.LarsCode = 100002; //add a retired version to have same IfateReferenceNumber and different LarsCode allStandards.Add(activeValidStandards.Select(x => new Standard { IfateReferenceNumber = x.IfateReferenceNumber, Status = "Retired", LarsCode = 100001, Version = 1, LarsStandard = newActiveVersion.LarsStandard }).First()); mockDataContext .Setup(context => context.Standards) .ReturnsDbSet(allStandards); var count = await repository.Count(StandardFilter.Active); count.Should().Be(activeValidStandards.Count + activeInvalidStandards.Count + retiredStandards.Count + 1); }