コード例 #1
0
        public PolicyServiceTest()
        {
            var policyData        = PolicyListStub.GetStringData();
            var clientHandlerStub = new DelegatingHandlerStub(policyData);
            var client            = new HttpClient(clientHandlerStub);

            _httpClient.Setup(_ => _.CreateClient(It.IsAny <string>())).Returns(client);
            var clients = new List <Client>();

            _service = new PolicyService(_httpClient.Object, _client.Object);
        }
コード例 #2
0
        public void Get_Policy_By_Policy_Number_Must_Return_A_Policy()
        {
            var stubPolicy = PolicyListStub.GetFirst();
            var policy     = _service.GetPolicyByPolicyNumber(stubPolicy.Id);

            Assert.IsNotNull(policy);
            Assert.AreEqual(policy.Id, stubPolicy.Id);
            Assert.AreEqual(policy.Email, stubPolicy.Email);
            Assert.AreEqual(policy.AmountInsured, stubPolicy.AmountInsured);
            Assert.AreEqual(policy.InstallmentPayment, stubPolicy.InstallmentPayment);
            Assert.AreEqual(policy.ClientId, stubPolicy.ClientId);
        }
コード例 #3
0
        public void Get_Client_By_Policy_Number_Must_Return_A_Policy()
        {
            var stubClient = ClientListStub.GetFirst();
            var stubPolicy = PolicyListStub.GetFirst();

            _client.Setup(x => x.getClientById(stubClient.Id)).Returns(stubClient);

            var client = _service.getClientByPolicyNumber(stubPolicy.Id);

            Assert.IsNotNull(client);
            Assert.AreEqual(client.Email, stubClient.Email);
            Assert.AreEqual(client.Id, stubClient.Id);
            Assert.AreEqual(client.Name, stubClient.Name);
            Assert.AreEqual(client.Role, stubClient.Role);
        }
コード例 #4
0
        public void Get_Client_By_User_Name_Must_Return_Client()
        {
            var clientStub = ClientListStub.GetFirst();
            var stubPolicy = PolicyListStub.GetFirst();

            _service.Setup(x => x.getClientByPolicyNumber(stubPolicy.Id)).Returns(ClientListStub.GetFirst());

            var result = _controller.GetClientByPolicyNumber(stubPolicy.Id) as OkObjectResult;
            var client = result.Value as Client;

            Assert.IsInstanceOf <OkObjectResult>(result);
            Assert.IsNotNull(result.Value);
            Assert.AreEqual(client.Id, clientStub.Id);
            Assert.AreEqual(client.Email, clientStub.Email);
        }
コード例 #5
0
        public void Get_Client_By_Id_Must_Return_Client()
        {
            var clientStub = ClientListStub.GetFirst();
            var stubPolicy = PolicyListStub.GetFirst();

            _service.Setup(x => x.GetListOfPoliciesByUserName(clientStub.Email)).Returns(PolicyListStub.GetAll());

            var result   = _controller.GetPoliciesByUserName(clientStub.Email) as OkObjectResult;
            var policies = result.Value as IEnumerable <Policy>;

            Assert.IsInstanceOf <OkObjectResult>(result);
            Assert.IsNotNull(result.Value);
            Assert.AreEqual(policies.ToList().First().Id, stubPolicy.Id);
            Assert.AreEqual(policies.ToList().First().Email, stubPolicy.Email);
        }
コード例 #6
0
        public void Get_List_Of_Policies_By_UserName_Must_Return_A_List()
        {
            var stubClient = ClientListStub.GetFirst();
            var stubPolicy = PolicyListStub.GetFirst();

            _client.Setup(x => x.getClientByEmail(stubClient.Email)).Returns(stubClient);

            var policies = _service.GetListOfPoliciesByUserName(stubClient.Email);

            Assert.IsNotNull(policies);
            Assert.IsTrue(policies.ToArray().Length > 0);
            Assert.AreEqual(policies.First().Id, stubPolicy.Id);
            Assert.AreEqual(policies.First().Email, stubPolicy.Email);
            Assert.AreEqual(policies.First().AmountInsured, stubPolicy.AmountInsured);
            Assert.AreEqual(policies.First().InstallmentPayment, stubPolicy.InstallmentPayment);
            Assert.AreEqual(policies.First().ClientId, stubPolicy.ClientId);
        }