Exemple #1
0
        public void AddPolicy_Maps_ConstuctionTypes_To_SelectedList()
        {
            //Arrange

            var buildingTypes = new List <BuildingType>()
            {
                new BuildingType
                {
                    Id   = "1",
                    Name = "One"
                },
                new BuildingType
                {
                    Id   = "2",
                    Name = "Two"
                }
            }.AsEnumerable();

            //Act
            var sut = new AddPolicy(buildingTypes);

            //Assert
            var expectedList = buildingTypes.ToList();
            var actualList   = sut.RiskConstruction.ToList();

            for (int i = 0; i < expectedList.Count; i++)
            {
                Assert.AreEqual(expectedList[i].Name, actualList[i].Text);
                Assert.AreEqual(expectedList[i].Id, actualList[i].Value);
            }
        }
        public async Task <string> Save(AddPolicy addPolicy)
        {
            var insurancePolicy = Mapper.Map <InsurancePolicy>(addPolicy);
            var serialized      = JsonConvert.SerializeObject(insurancePolicy);
            var content         = new StringContent(serialized, Encoding.UTF8, "application/json");
            var response        = await this.Client.PostAsync("api/Policy/add", content);

            response.EnsureSuccessStatusCode();
            return(await response.Content.ReadAsStringAsync());
        }
Exemple #3
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))));
        }
 /// <summary>
 /// Adds insurance policy into database.Clear policy number field, thanks by this You can add next insurance policy
 /// by write new number, other fields are already filled.
 /// </summary>
 private void AddPolicyToDatabaseButton(object sender, RoutedEventArgs e)
 {
     AddPolicy.UserPolicyToDatabase(policyNumberTextField.Text, addDate.DisplayDate, brokerNameTextField.Text);
     policyNumberTextField.Clear();
 }
 public async Task <string> Add(AddPolicy addPolicy)
 {
     return(await this.PolicyServiceClient.Save(addPolicy));
 }
        void obradi()
        {
            try
            {
                int operacija = 0;
                while (operacija != (int)Operacije.Kraj)
                {
                    TransferKlasa transfer = formater.Deserialize(tok) as TransferKlasa;
                    switch (transfer.Operacija)
                    {
                    case Operacije.Login:
                        FindAgent fa = new FindAgent();
                        transfer.Rezultat = fa.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.AddClient:
                        AddClient ac = new AddClient();
                        transfer.Rezultat = ac.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.GetListClients:
                        GetLIstClients glc = new GetLIstClients();
                        transfer.Rezultat = glc.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.SearchClients:
                        SearchClients sc = new SearchClients();
                        transfer.Rezultat = sc.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.SelectClient:
                        SelectClient scl = new SelectClient();
                        transfer.Rezultat = scl.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.UpdateClient:
                        UpdateClient uc = new UpdateClient();
                        transfer.Rezultat = uc.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.AddPolicy:
                        AddPolicy ap = new AddPolicy();
                        transfer.Rezultat = ap.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.UpdatePolicy:
                        UpdatePolicy up = new UpdatePolicy();
                        transfer.Rezultat = up.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.DeletePolicy:
                        DeletePolicy dp = new DeletePolicy();
                        transfer.Rezultat = dp.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.SearchPolicy:
                        SearchPolicy sp = new SearchPolicy();
                        transfer.Rezultat = sp.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.SelectPolicy:
                        SelectPolicy spo = new SelectPolicy();
                        transfer.Rezultat = spo.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.GetListInsTypes:
                        GetListInsuranceTypes git = new GetListInsuranceTypes();
                        transfer.Rezultat = git.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.DeleteClient:
                        DeleteClient dc = new DeleteClient();
                        transfer.Rezultat = dc.IzvrsiSO(transfer.TransferObjekat as OpstiDomenskiObjekat);
                        formater.Serialize(tok, transfer);
                        break;

                    case Operacije.Kraj:
                        operacija = 1;
                        Server.listaTokova.Remove(tok);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception)
            {
                Server.listaTokova.Remove(tok);
            }
        }