public void UpdateWithMissingDto_NotFoundException() { var repo = new Mock <IResourceRepository>(); repo.Setup(x => x.Get("foo", "foo")).Returns((Resource)null); var domain = new ResourceDomain(repo.Object); Should.Throw <NotFoundException>(() => domain.Update(new ResourceDto { Key = "foo", Partition = "foo" })); }
public void UpdateWithExistingDto_ValueIsUpdated() { var repo = new Mock <IResourceRepository>(); repo.Setup(x => x.Get("foo", "foo")).Returns(new Resource { Key = "foo", Partition = "foo", Value = "foo" }); var domain = new ResourceDomain(repo.Object); domain.Update(new ResourceDto { Key = "foo", Partition = "foo", Value = "bar" }); repo.Verify(x => x.Update(It.Is <Resource>(y => y.Key == "foo" && y.Partition == "foo" && y.Value == "bar"))); }
public void UpdateWithNullDto_ThrowsBadRequestException() { var domain = new ResourceDomain(null); Should.Throw <BadRequestException>(() => domain.Update(null)); }