public async Task DownloadAsync_ShouldReturn_Null_IfContractDoNotExists()
        {
            var db            = GetDatabase();
            var mapper        = GetMapper();
            var firstContract = new Contract {
                Id = 1, IsDeleted = false, ScannedContract = new byte[] { 123 }
            };
            var secondContract = new Contract {
                Id = 2, IsDeleted = false, ScannedContract = new byte[] { 1 }
            };
            var thirdContract = new Contract {
                Id = 3, IsDeleted = false, ScannedContract = new byte[] { 34 }
            };

            await db.Contracts.AddRangeAsync(firstContract, secondContract, thirdContract);

            await db.SaveChangesAsync();

            var contractService = new ContractsService(mapper, db);

            var result = await contractService.DownloadAsync(4);

            result
            .Should()
            .BeNull();
        }
        public async Task DeleteAsync_ShouldReturn_True_IfContractExistsAndNotDeleted()
        {
            var db            = GetDatabase();
            var mapper        = GetMapper();
            var firstContract = new Contract {
                Id = 1, IsDeleted = false, ScannedContract = new byte[] { 123 }
            };
            var secondContract = new Contract {
                Id = 2, IsDeleted = false, ScannedContract = new byte[] { 1 }
            };
            var thirdContract = new Contract {
                Id = 3, IsDeleted = false, ScannedContract = new byte[] { 34 }
            };

            await db.Contracts.AddRangeAsync(firstContract, secondContract, thirdContract);

            await db.SaveChangesAsync();

            var contractService = new ContractsService(mapper, db);

            var result = await contractService.DeleteAsync(2);

            var deletedContract = await db.Contracts.FindAsync(2);

            result
            .Should()
            .BeTrue();


            deletedContract
            .Should()
            .BeOfType <Contract>()
            .And
            .Match <Contract>(c => c.IsDeleted == true);
        }
        public async Task DownloadAsync_ShouldReturn_CorrectByteArray_IfContractExists()
        {
            var db            = GetDatabase();
            var mapper        = GetMapper();
            var firstContract = new Contract {
                Id = 1, IsDeleted = false, ScannedContract = new byte[] { 123 }
            };
            var secondContract = new Contract {
                Id = 2, IsDeleted = false, ScannedContract = new byte[] { 1 }
            };
            var thirdContract = new Contract {
                Id = 3, IsDeleted = false, ScannedContract = new byte[] { 34 }
            };

            await db.Contracts.AddRangeAsync(firstContract, secondContract, thirdContract);

            await db.SaveChangesAsync();

            var contractService = new ContractsService(mapper, db);

            var result = await contractService.DownloadAsync(1);

            var scandContract = new byte[] { 123 };

            result
            .Should()
            .BeOfType <byte[]>()
            .And
            .Match <byte[]>(c => c.Length == scandContract.Length);
        }
        private void ButDel_Click(object sender, EventArgs e)
        {
            if (lBContracts.SelectedItem != null)
            {
                ContractsService.Delete((lBContracts.SelectedItem as ContractDTO).Id);

                ReloadedContracts();
            }
        }
Пример #5
0
 public ContractsController(ContractsService serv)
 {
     _serv = serv;
 }
 public ContractsController(ContractsService service)
 {
     _service = service;
 }