public void GetOrderClientCards() { var clientCardFromBody2 = new ClientCardFromBody( "2", "Антон", "ЕКБ", "8", "*****@*****.**", "TV", "Display", "Sergey", "123", new DateTime(2018, 01, 01), new DateTime(2018, 01, 01), new string[] { "sr" }, new string[][] { new string[] { "resistor1", "10" }, new string[] { "resistor2", "15" } }); var options = SetOptions("Get_order_client_card"); var dbService = new ClientCardDatabaseService(options); var clientCard2 = ClientCard.ConvertToClientCard(clientCardFromBody2); var clientCard = ClientCard.ConvertToClientCard(ClientCardFromBody); var context = new ClientCardContext(options); dbService.AddClientCardWithContext(clientCard2, context); dbService.AddClientCardWithContext(clientCard, context); var db = dbService.GetAllClientCardsWithContext(context); db.First().ContractId.Should().Be(1); }
public void CanConvertToClientCard() { var clientCard = ClientCard.ConvertToClientCard(this.clientCardFromBody); SetDefaultGuid(this.client, clientCard); clientCard.Should().BeEquivalentTo(this.client); }
public void CanNotConvertNullToCardClient() { ClientCardFromBody clientFromBody = null; Action act = () => ClientCard.ConvertToClientCard(clientFromBody); act.Should().Throw <EntitiesException>() .WithMessage("Input can not be null"); }
public void CanGetAllClientCards() { var options = SetOptions("Get_all_client_card"); var dbService = new ClientCardDatabaseService(options); var clientCard = ClientCard.ConvertToClientCard(ClientCardFromBody); var context = new ClientCardContext(options); dbService.AddClientCardWithContext(clientCard, context); var db = dbService.GetAllClientCardsWithContext(context); db.FirstOrDefault()?.Works.FirstOrDefault()?.Name.Should().Be("sr"); }
public void CanAddRepairEquipments() { var options = SetOptions("Add_repair_equipments"); var dbService = new ClientCardDatabaseService(options); var clientCard = ClientCard.ConvertToClientCard(ClientCardFromBody); var context = new ClientCardContext(options); dbService.AddClientCardWithContext(clientCard, context); var db = dbService.GetAllClientCardsWithContext(context); db.FirstOrDefault()?.RepairEquipments.FirstOrDefault()?.Name.Should().Be("resistor1"); }
public void CanGetContractCount() { var options = SetOptions("Get_count_client_card"); var dbService = new ClientCardDatabaseService(options); var clientCard = ClientCard.ConvertToClientCard(ClientCardFromBody); var context = new ClientCardContext(options); dbService.AddClientCardWithContext(clientCard, context); var count = dbService.GetContractCountWithContext(context); count.Should().Be(1); }
public IActionResult Save([FromBody] ClientCardFromBody clientCardFromBody) { try { var clientCard = ClientCard.ConvertToClientCard(clientCardFromBody); var xmlData = ClientCardSerializeService.SerializeDataToXml(clientCard, this.encode); var bytes = this.encode.GetBytes(xmlData); return(this.File(bytes, "application/otcet-stream", "client.xml")); } catch (EntitiesException ex) { return(this.StatusCode(406, ex.Message)); } }
public void CanNotPutDateYearOverThreeThousand() { var clientFromBody = new ClientCardFromBody( "1", "Антон", "ЕКБ", "8", "*****@*****.**", "TV", "Display", "Sergey", "123", new DateTime(3050, 01, 01), new DateTime(2018, 03, 01), new[] { "sr" }, new[] { new[] { "resistor1", "10" }, new[] { "resistor2", "15" } }); Action act = () => ClientCard.ConvertToClientCard(clientFromBody); act.Should().Throw <EntitiesException>() .WithMessage("Invalid year"); }
public void CanNotConvertToCardClientWithoutWorks() { var clientFromBody = new ClientCardFromBody( "1", "Антон", "ЕКБ", "8", "*****@*****.**", "TV", "Display", "Sergey", "123", new DateTime(2018, 01, 01), new DateTime(2018, 03, 01), new string[] { }, new[] { new[] { "resistor1", "10" }, new[] { "resistor2", "15" } }); Action act = () => ClientCard.ConvertToClientCard(clientFromBody); act.Should().Throw <EntitiesException>() .WithMessage("Works can not be null"); }
public IActionResult SaveDatabase([FromBody] ClientCardFromBody clientCardFromBody) { ClientCard clientCard; try { clientCard = ClientCard.ConvertToClientCard(clientCardFromBody); } catch (EntitiesException ex) { return(this.StatusCode(406, ex.Message)); } try { this.dbService.AddClientCardWithContext(clientCard, this.context); return(this.Ok("Saved")); } catch (DatabaseException ex) { return(this.StatusCode(208, ex.Message)); } }