Ejemplo n.º 1
0
        public async Task HandleAsync_SendsEmailWithDataReturnYear()
        {
            // Arrange
            string emailAddress       = "*****@*****.**";
            var    competentAuthority = new UKCompetentAuthority(Guid.NewGuid(), "Name", "Abbreviation", A.Dummy <Country>(), emailAddress, 0);

            Scheme scheme = A.Fake <Scheme>();

            A.CallTo(() => scheme.CompetentAuthority)
            .Returns(competentAuthority);

            Quarter quarter = new Quarter(2015, QuarterType.Q1);

            DataReturn        dataReturn        = new DataReturn(scheme, quarter);
            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            dataReturnVersion.Submit("testUserId");

            var schemeSubmissionEvent = new SchemeDataReturnSubmissionEvent(dataReturnVersion);

            var emailService = A.Fake <IWeeeEmailService>();
            var dataAccess   = A.Dummy <ISchemeDataReturnSubmissionEventHandlerDataAccess>();
            var handler      = new SchemeDataReturnSubmissionEventHandler(emailService, dataAccess);

            // Act
            await handler.HandleAsync(schemeSubmissionEvent);

            // Assert
            A.CallTo(() => emailService.SendSchemeDataReturnSubmitted(A <string> ._, A <string> ._, 2015, A <int> ._, A <bool> ._))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
        public async Task HandleAsync_SendsEmailWithSchemeName()
        {
            // Arrange
            string emailAddress = "*****@*****.**";
            var competentAuthority = new UKCompetentAuthority(Guid.NewGuid(), "Name", "Abbreviation", A.Dummy<Country>(), emailAddress);

            Scheme scheme = A.Fake<Scheme>();
            A.CallTo(() => scheme.CompetentAuthority)
                .Returns(competentAuthority);
            A.CallTo(() => scheme.SchemeName)
                .Returns("Test Scheme Name");

            Quarter quarter = new Quarter(2016, QuarterType.Q1);

            DataReturn dataReturn = new DataReturn(scheme, quarter);
            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);
            dataReturnVersion.Submit("testUserId");

            var schemeSubmissionEvent = new SchemeDataReturnSubmissionEvent(dataReturnVersion);

            var emailService = A.Fake<IWeeeEmailService>();
            var dataAccess = A.Dummy<ISchemeDataReturnSubmissionEventHandlerDataAccess>();
            var handler = new SchemeDataReturnSubmissionEventHandler(emailService, dataAccess);

            // Act
            await handler.HandleAsync(schemeSubmissionEvent);

            // Assert
            A.CallTo(() => emailService.SendSchemeDataReturnSubmitted(A<string>._, "Test Scheme Name", A<int>._, A<int>._, A<bool>._))
                .MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 3
0
        public async Task HandleAsync_InvokesDataAccess_GetNumberOfDataReturnSubmissionsAsync_WithCorrectParameters()
        {
            // Arrange
            string emailAddress       = "*****@*****.**";
            var    competentAuthority = new UKCompetentAuthority(Guid.NewGuid(), "Name", "Abbreviation", A.Dummy <Country>(), emailAddress, 0);

            Scheme scheme = A.Fake <Scheme>();

            A.CallTo(() => scheme.CompetentAuthority)
            .Returns(competentAuthority);

            Quarter quarter = new Quarter(2016, QuarterType.Q2);

            DataReturn        dataReturn        = new DataReturn(scheme, quarter);
            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);

            dataReturnVersion.Submit("testUserId");

            var dataAccess   = A.Fake <ISchemeDataReturnSubmissionEventHandlerDataAccess>();
            var emailService = A.Fake <IWeeeEmailService>();
            var handler      = new SchemeDataReturnSubmissionEventHandler(emailService, dataAccess);

            var schemeSubmissionEvent = new SchemeDataReturnSubmissionEvent(dataReturnVersion);

            // Act
            await handler.HandleAsync(schemeSubmissionEvent);

            // Assert
            A.CallTo(() => dataAccess.GetNumberOfDataReturnSubmissionsAsync(scheme, 2016, QuarterType.Q2))
            .MustHaveHappened();
        }
        public async Task HandleAsync_InvokesDataAccess_GetNumberOfDataReturnSubmissionsAsync_WithCorrectParameters()
        {
            // Arrange
            string emailAddress = "*****@*****.**";
            var competentAuthority = new UKCompetentAuthority(Guid.NewGuid(), "Name", "Abbreviation", A.Dummy<Country>(), emailAddress);

            Scheme scheme = A.Fake<Scheme>();
            A.CallTo(() => scheme.CompetentAuthority)
                .Returns(competentAuthority);

            Quarter quarter = new Quarter(2016, QuarterType.Q2);

            DataReturn dataReturn = new DataReturn(scheme, quarter);
            DataReturnVersion dataReturnVersion = new DataReturnVersion(dataReturn);
            dataReturnVersion.Submit("testUserId");

            var dataAccess = A.Fake<ISchemeDataReturnSubmissionEventHandlerDataAccess>();
            var emailService = A.Fake<IWeeeEmailService>();
            var handler = new SchemeDataReturnSubmissionEventHandler(emailService, dataAccess);

            var schemeSubmissionEvent = new SchemeDataReturnSubmissionEvent(dataReturnVersion);

            // Act
            await handler.HandleAsync(schemeSubmissionEvent);

            // Assert
            A.CallTo(() => dataAccess.GetNumberOfDataReturnSubmissionsAsync(scheme, 2016, QuarterType.Q2))
                .MustHaveHappened();
        }