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 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 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_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);
        }
Exemple #5
0
        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
            });
        }