Пример #1
0
        public async Task InsurancePolicyController_Get_Add_Returns_PartialView()
        {
            //Arrange
            var httpClientMock = new Mock <IPolicyServiceClient>();
            var sut            = new InsurancePolicyController(httpClientMock.Object);

            //Act
            await sut.Add();

            //Assert
            httpClientMock.Verify(x => x.GetConstructionTypes(), Times.Once);
        }
Пример #2
0
        public async Task InsurancePolicyController_Post_Add_Calls_Client_Save()
        {
            //Arrange
            var httpClientMock = new Mock <IPolicyServiceClient>();
            var sut            = new InsurancePolicyController(httpClientMock.Object);
            var addPolicy      = new AddPolicy();

            //Act
            await sut.Add(addPolicy);

            //Assert
            httpClientMock.Verify(x => x.Save(It.Is <AddPolicy>(y => y.Equals(addPolicy))));
        }
        public void Post_InsurancePolicy_ShouldRetornCreated()
        {
            var insurance = new InsurancePolicy();

            var service = new Mock <IInsurancePolicyServices>();

            service.Setup(i => i.CreateInsurancePolicy(insurance)).Returns(new InsurancePolicy());

            var controller = new InsurancePolicyController();
            var result     = controller.Post(insurance);

            Assert.AreEqual(result.GetType(), typeof(CreatedNegotiatedContentResult <InsurancePolicy>));
        }
        public void Get_InsurancePolicy_ShouldReturnOk()
        {
            var id   = 1;
            var list = new List <InsurancePolicy>();


            var service = new Mock <IInsurancePolicyServices>();

            service.Setup(i => i.GetInsurancePolicy(id)).Returns(list.AsQueryable());

            var controller = new InsurancePolicyController();
            var result     = controller.Get(id);

            Assert.AreEqual(result.GetType(), typeof(OkNegotiatedContentResult <InsurancePolicy>));
        }
Пример #5
0
        public async Task InsurancePolicyController_Index_Returns_View()
        {
            //Arrange
            var displayPolicy  = new DisplayPolicy();
            var httpClientMock = new Mock <IPolicyServiceClient>();
            var sut            = new InsurancePolicyController(httpClientMock.Object);

            httpClientMock.Setup(x => x.FetchAll()).ReturnsAsync(new List <DisplayPolicy> {
                displayPolicy
            });

            //Act
            await sut.Index();

            //Assert
            httpClientMock.Verify(x => x.FetchAll(), Times.Once);
        }