コード例 #1
0
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void TaskSuccessTest()
        {
            var addRecordLabel     = new AddRecordLabel(DbContext, new FormattingService());
            var testRecordLabel1   = TestsModel.RecordLabel;
            var testRecordLabel1Id = addRecordLabel.DoTask(testRecordLabel1);

            Assert.IsTrue(testRecordLabel1Id.Data.HasValue);
            addRecordLabel = new AddRecordLabel(DbContext, new FormattingService());
            var testRecordLabel2   = TestsModel.RecordLabel;
            var testRecordLabel2Id = addRecordLabel.DoTask(testRecordLabel2);

            Assert.IsTrue(testRecordLabel2Id.Data.HasValue);

            var task   = new ListRecordLabels(DbContext);
            var result = task.DoTask(null);

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

            var recordLabels = result.Data;

            Assert.IsNotNull(recordLabels);
            Assert.IsTrue(recordLabels.Count >= 2);

            var recordLabel1 = recordLabels.SingleOrDefault(p => p.Id == testRecordLabel1Id.Data.Value);

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

            var recordLabel2 = recordLabels.SingleOrDefault(p => p.Id == testRecordLabel2Id.Data.Value);

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

            var removeRecordLabel = new RemoveRecordLabel(DbContext);
            var removeResult1     = removeRecordLabel.DoTask(recordLabel1);
            var removeResult2     = removeRecordLabel.DoTask(recordLabel2);

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

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