public void TaskFailTest() { var task = new UpdateArtist(EmptyDbContext, new FormattingService()); var result = task.DoTask(null); Assert.IsFalse(result.Success); Assert.IsNotNull(result.Exception); }
public void TaskSuccessTest() { var testArtist = TestsModel.Artist; var addArtistTask = new AddArtist(DbContext, new FormattingService()); var addArtistResult = addArtistTask.DoTask(testArtist); Assert.IsTrue(addArtistResult.Success); Assert.IsNull(addArtistResult.Exception); var task = new UpdateArtist(DbContext, new FormattingService()); var toUpdate = testArtist; UpdateArtistModel(toUpdate); var result = task.DoTask(toUpdate); Assert.IsTrue(result.Success); Assert.IsNull(result.Exception); Assert.IsNull(result.Data); var getArtistTask = new GetArtist(DbContext); var artist = getArtistTask.DoTask(toUpdate.Id)?.Data; var formattingService = new FormattingService(); Assert.IsNotNull(artist); Assert.AreEqual(toUpdate.Name, artist.Name); Assert.AreEqual(formattingService.FormatTaxId(toUpdate.TaxId), artist.TaxId); Assert.AreEqual(toUpdate.Email, artist.Email); Assert.AreEqual(toUpdate.Address.Street, artist.Address.Street); Assert.AreEqual(toUpdate.Address.City, artist.Address.City); Assert.AreEqual(toUpdate.Address.Region, artist.Address.Region); Assert.AreEqual(toUpdate.Address.PostalCode, artist.Address.PostalCode); Assert.AreEqual(toUpdate.Address.Country.Name, artist.Address.Country.Name); Assert.AreEqual(toUpdate.HasServiceMark, artist.HasServiceMark); Assert.AreEqual(toUpdate.WebsiteUrl, artist.WebsiteUrl); Assert.AreEqual(toUpdate.PressKitUrl, artist.PressKitUrl); if (testArtist.RecordLabel != null) { Assert.AreEqual(toUpdate.RecordLabel.Name, artist.RecordLabel.Name); Assert.AreEqual(formattingService.FormatTaxId(toUpdate.RecordLabel.TaxId), artist.RecordLabel.TaxId); Assert.AreEqual(toUpdate.RecordLabel.Email, artist.RecordLabel.Email); Assert.AreEqual(formattingService.FormatPhoneNumber(toUpdate.RecordLabel.Phone), artist.RecordLabel.Phone); Assert.IsNotNull(toUpdate.RecordLabel.Address); Assert.AreEqual(toUpdate.RecordLabel.Address.Street, artist.RecordLabel.Address.Street); Assert.AreEqual(toUpdate.RecordLabel.Address.City, artist.RecordLabel.Address.City); Assert.AreEqual(toUpdate.RecordLabel.Address.Region, artist.RecordLabel.Address.Region); Assert.AreEqual(toUpdate.RecordLabel.Address.PostalCode, artist.RecordLabel.Address.PostalCode); Assert.IsNotNull(toUpdate.RecordLabel.Address.Country); Assert.AreEqual(toUpdate.RecordLabel.Address.Country.Name, artist.RecordLabel.Address.Country.Name); Assert.AreEqual(toUpdate.RecordLabel.Address.Country.IsoCode, artist.RecordLabel.Address.Country.IsoCode); } var removeArtistTask = new RemoveArtist(DbContext); var removeArtistResult = removeArtistTask.DoTask(artist); Assert.IsTrue(removeArtistResult.Success); Assert.IsNull(removeArtistResult.Exception); }