Пример #1
0
        public void Should_put_a_topic()
        {
            var groupPut = new F.GroupPut()
            {
                Id          = F.Identity.Random(),
                Description = "description",
                ParentId    = F.Identity.Random(),
                Name        = "test"
            };

            var parent = new M.Group {
                Id = groupPut.ParentId.ToModel()
            };
            var group = new M.Group()
            {
                Description = groupPut.Description,
                ParentId    = parent.Id,
                Id          = groupPut.Id.ToModel(),
                Name        = groupPut.Name
            };


            mockedUpdateCommand.Setup(r => r.Execute(It.IsAny <M.Group>()));
            client.ExecutePut(groupPut.Id.ToString(), groupPut);

            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t != null)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.Description == groupPut.Description)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.Name == groupPut.Name)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.ParentId == groupPut.ParentId.ToModel())));
        }
        public void FacadePutToModelMapsCorrectly()
        {
            var facade = new GroupPut
                             {
                                 Description = _description,
                                 Id = _id,
                                 Name = _name,
                                 ParentId = _parentId
                             };

            var model = facade.ToModel();

            Assert.That(model.Description, Is.EqualTo(_description));
            Assert.That(model.Name, Is.EqualTo(_name));
            Assert.That(model.Id, Is.EqualTo(_id.ToModel()));
            Assert.That(model.ParentId, Is.EqualTo(_parentId.ToModel()));
        }
Пример #3
0
        public void Validates_a_put_with_an_invalid_GroupId()
        {
            var groupPut = new F.GroupPut()
            {
                Id          = F.Identity.Random(),
                Description = "description",
                Name        = string.Empty,
                ParentId    = F.Identity.Random()
            };

            mockedUpdateCommand.Setup(r => r.Execute(It.IsAny <M.Group>())).Throws <EntityNotFoundException>();

            var result = client.ExecutePut <F.GroupPut, F.Group>(groupPut.Id.ToString(), groupPut, HttpStatusCode.NotFound);

            Assert.IsNull(result);

            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t != null)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.Id == groupPut.Id.ToModel())));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.Description == groupPut.Description)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.Name == groupPut.Name)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is <M.Group>(t => t.ParentId == groupPut.ParentId.ToModel())));
        }
Пример #4
0
        public void Should_put_a_topic()
        {
            var groupPut = new F.GroupPut()
                               {
                                   Id = F.Identity.Random(),
                                   Description = "description",
                                   ParentId = F.Identity.Random(),
                                   Name = "test"
                               };

            var parent = new M.Group {Id = groupPut.ParentId.ToModel()};
            var group = new M.Group()
                            {
                                Description = groupPut.Description,
                                ParentId = parent.Id,
                                Id = groupPut.Id.ToModel(),
                                Name = groupPut.Name
                            };

            mockedUpdateCommand.Setup(r => r.Execute(It.IsAny<M.Group>()));
            client.ExecutePut(groupPut.Id.ToString(), groupPut);

            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t != null)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.Description == groupPut.Description)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.Name == groupPut.Name)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.ParentId == groupPut.ParentId.ToModel())));
        }
Пример #5
0
        public void Validates_a_put_with_a_ValidationError()
        {
            var groupPut = new F.GroupPut()
            {
                Id = F.Identity.Random(),
                Description = "description",
                Name = string.Empty,
                ParentId = F.Identity.Random()
            };

            mockedUpdateCommand.Setup(r => r.Execute(It.IsAny<M.Group>())).Throws(new ValidationException("foo"));

            var result = client.ExecutePut<F.GroupPut, F.Group>(groupPut.Id.ToString(), groupPut, HttpStatusCode.BadRequest);

            Assert.IsNull(result);

            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t != null)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.Id == groupPut.Id.ToModel())));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.Description == groupPut.Description)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.Name == groupPut.Name)));
            mockedUpdateCommand.Verify(r => r.Execute(It.Is<M.Group>(t => t.ParentId == groupPut.ParentId.ToModel())));
        }