예제 #1
0
        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"
            }));
        }
예제 #2
0
        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")));
        }
예제 #3
0
        public void UpdateWithNullDto_ThrowsBadRequestException()
        {
            var domain = new ResourceDomain(null);

            Should.Throw <BadRequestException>(() => domain.Update(null));
        }