Esempio n. 1
0
        public async Task GetIndex_Always_ReturnsIndexView()
        {
            // Arrange
            DataReturnsController controller = new DataReturnsController(
                () => A.Dummy <IWeeeClient>(),
                A.Dummy <IWeeeCache>(),
                A.Dummy <BreadcrumbService>(),
                A.Dummy <CsvWriterFactory>(),
                A.Dummy <IMapper>(),
                A.Dummy <ConfigurationService>());

            // Act
            ActionResult result = await controller.Index(A.Dummy <Guid>());

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || string.Equals("Index", viewResult.ViewName, StringComparison.InvariantCultureIgnoreCase));
        }
Esempio n. 2
0
        public async Task GetIndex_CallsApiToFetchSummary_AndPopulatesViewModel()
        {
            IWeeeClient client = A.Fake <IWeeeClient>();

            List <int> complianceYearsForScheme = new List <int>()
            {
                2016, 2017, 2018
            };

            A.CallTo(() => client.SendAsync(A <string> ._, A <FetchDataReturnComplianceYearsForScheme> ._))
            .WhenArgumentsMatch(a => a.Get <FetchDataReturnComplianceYearsForScheme>("request").PcsId == new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"))
            .Returns(complianceYearsForScheme);

            // Arrange
            DataReturnsController controller = new DataReturnsController(
                () => client,
                A.Dummy <IWeeeCache>(),
                A.Dummy <BreadcrumbService>(),
                A.Dummy <CsvWriterFactory>(),
                A.Dummy <IMapper>(),
                A.Dummy <ConfigurationService>());

            // Act
            ActionResult result = await controller.Index(new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"));

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            IndexViewModel viewModel = viewResult.Model as IndexViewModel;

            Assert.NotNull(viewModel);

            Assert.Equal(new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"), viewModel.OrganisationId);
            Assert.Collection(viewModel.ComplianceYears,
                              r1 => Assert.Equal(2016, r1),
                              r2 => Assert.Equal(2017, r2),
                              r3 => Assert.Equal(2018, r3));
        }
        public async Task GetIndex_CallsApiToFetchSummary_AndPopulatesViewModel()
        {
            IWeeeClient client = A.Fake<IWeeeClient>();

            List<int> complianceYearsForScheme = new List<int>() { 2016, 2017, 2018 };

            A.CallTo(() => client.SendAsync(A<string>._, A<FetchDataReturnComplianceYearsForScheme>._))
                .WhenArgumentsMatch(a => a.Get<FetchDataReturnComplianceYearsForScheme>("request").PcsId == new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"))
                .Returns(complianceYearsForScheme);

            // Arrange
            DataReturnsController controller = new DataReturnsController(
                () => client,
                A.Dummy<IWeeeCache>(),
                A.Dummy<BreadcrumbService>(),
                A.Dummy<CsvWriterFactory>(),
                A.Dummy<IMapper>(),
                A.Dummy<ConfigurationService>());

            // Act
            ActionResult result = await controller.Index(new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"));

            // Assert
            ViewResult viewResult = result as ViewResult;
            Assert.NotNull(viewResult);

            IndexViewModel viewModel = viewResult.Model as IndexViewModel;
            Assert.NotNull(viewModel);

            Assert.Equal(new Guid("BA7F772F-626D-4CBD-8D50-50A7B852A9AC"), viewModel.OrganisationId);
            Assert.Collection(viewModel.ComplianceYears,
                r1 => Assert.Equal(2016, r1),
                r2 => Assert.Equal(2017, r2),
                r3 => Assert.Equal(2018, r3));
        }
        public async Task GetIndex_Always_ReturnsIndexView()
        {
            // Arrange
            DataReturnsController controller = new DataReturnsController(
                () => A.Dummy<IWeeeClient>(),
                A.Dummy<IWeeeCache>(),
                A.Dummy<BreadcrumbService>(),
                A.Dummy<CsvWriterFactory>(),
                A.Dummy<IMapper>(),
                A.Dummy<ConfigurationService>());

            // Act
            ActionResult result = await controller.Index(A.Dummy<Guid>());

            // Assert
            ViewResult viewResult = result as ViewResult;
            Assert.NotNull(viewResult);

            Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || string.Equals("Index", viewResult.ViewName, StringComparison.InvariantCultureIgnoreCase));
        }