Пример #1
0
        public void TaskFailTest()
        {
            var task   = new GetRecordLabel(EmptyDbContext);
            var result = task.DoTask(0);

            Assert.IsFalse(result.Success);
            Assert.IsNotNull(result.Exception);
        }
        public void TaskSuccessTest()
        {
            var testRecordLabel      = TestsModel.RecordLabel;
            var addRecordLabelTask   = new AddRecordLabel(DbContext, new FormattingService());
            var addRecordLabelResult = addRecordLabelTask.DoTask(testRecordLabel);

            Assert.IsTrue(addRecordLabelResult.Success);
            Assert.IsNull(addRecordLabelResult.Exception);

            var task     = new UpdateRecordLabel(DbContext, new FormattingService());
            var toUpdate = testRecordLabel;

            UpdateRecordLabelModel(toUpdate);
            var result = task.DoTask(toUpdate);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNull(result.Data);

            var getRecordLabelTask = new GetRecordLabel(DbContext);
            var recordLabel        = getRecordLabelTask.DoTask(toUpdate.Id)?.Data;
            var formattingService  = new FormattingService();

            Assert.IsNotNull(recordLabel);
            Assert.AreEqual(toUpdate.Name, recordLabel.Name);
            Assert.AreEqual(formattingService.FormatTaxId(toUpdate.TaxId), recordLabel.TaxId);
            Assert.AreEqual(toUpdate.Email, recordLabel.Email);
            Assert.AreEqual(formattingService.FormatPhoneNumber(toUpdate.Phone), recordLabel.Phone);
            Assert.AreEqual(toUpdate.Address.Street, recordLabel.Address.Street);
            Assert.AreEqual(toUpdate.Address.City, recordLabel.Address.City);
            Assert.AreEqual(toUpdate.Address.Region, recordLabel.Address.Region);
            Assert.AreEqual(toUpdate.Address.PostalCode, recordLabel.Address.PostalCode);
            Assert.AreEqual(toUpdate.Address.Country.Name, recordLabel.Address.Country.Name);

            var removeRecordLabelTask   = new RemoveRecordLabel(DbContext);
            var removeRecordLabelResult = removeRecordLabelTask.DoTask(recordLabel);

            Assert.IsTrue(removeRecordLabelResult.Success);
            Assert.IsNull(removeRecordLabelResult.Exception);
        }
Пример #3
0
        public void TaskSuccessTest()
        {
            var addRecordLabelTask = new AddRecordLabel(DbContext, new FormattingService());
            var testRecordLabel    = TestsModel.RecordLabel;
            var testRecordLabelId  = addRecordLabelTask.DoTask(testRecordLabel);

            Assert.IsTrue(testRecordLabelId.Data.HasValue);

            var task   = new GetRecordLabel(DbContext);
            var result = task.DoTask(testRecordLabelId.Data.Value);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);

            var recordLabel = result.Data;

            Assert.IsNotNull(recordLabel);
            Assert.AreEqual(testRecordLabel.Name, recordLabel.Name);
            Assert.AreEqual(testRecordLabel.TaxId, recordLabel.TaxId);
            Assert.AreEqual(testRecordLabel.Email, recordLabel.Email);
            Assert.AreEqual(testRecordLabel.Phone, recordLabel.Phone);
            Assert.IsNotNull(recordLabel.Address);
            Assert.AreEqual(testRecordLabel.Address.Street, recordLabel.Address.Street);
            Assert.AreEqual(testRecordLabel.Address.City, recordLabel.Address.City);
            Assert.AreEqual(testRecordLabel.Address.Region, recordLabel.Address.Region);
            Assert.AreEqual(testRecordLabel.Address.PostalCode, recordLabel.Address.PostalCode);
            Assert.IsNotNull(recordLabel.Address.Country);
            Assert.AreEqual(testRecordLabel.Address.Country.Name, recordLabel.Address.Country.Name);
            Assert.AreEqual(testRecordLabel.Address.Country.IsoCode, recordLabel.Address.Country.IsoCode);

            var removeRecordLabelTask = new RemoveRecordLabel(DbContext);
            var removeResult          = removeRecordLabelTask.DoTask(recordLabel);

            Assert.IsTrue(removeResult.Success);
            Assert.IsNull(removeResult.Exception);
        }