Example #1
0
        public void GetStatsInternVsCustomer_Validation_Test(DateTime startDate, object expected)
        {
            List <Registry>            dbRegistries     = new List <Registry>();
            Mock <IRegistryRepository> registryRepoMock = new Mock <IRegistryRepository>();

            registryRepoMock.Setup(r => r.GetRegistriesByDate(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>())).Returns(dbRegistries);

            Mock <IUnitOfWork> mockUOF = new Mock <IUnitOfWork>();

            mockUOF.Setup(uow => uow.RegistryRepository).Returns(registryRepoMock.Object);

            var controller = new StatisticsController(mockUOF.Object, httpContextAccessorMock);

            //Act
            var result = controller.GetStatsInternVsCustomer(startDate);

            if (expected.GetType() != StatusCodes.Status400BadRequest.GetType())
            {
                Assert.IsType(expected.GetType(), result.Value);
            }
            else
            {
                Assert.Equal(expected, (result.Result as ObjectResult).StatusCode);
            }
        }