Ejemplo n.º 1
0
        public void UpdateRule_WhereExists_ExpectRuleUpdated()
        {
            _repository.Stub(x => x.Update(Arg <int> .Is.Anything, Arg <Rule> .Is.Anything));
            _repository.Stub(x => x.CheckExists(Arg <int> .Is.Anything)).Return(true);

            var updatedRule = new Rule {
                Index = 12, Word = "boom", RuleType = RuleType.MultipleOf
            };
            var result = _target.UpdateRule(updatedRule.Index, updatedRule);

            Assert.IsNotNull(result);
            var response = result as OkNegotiatedContentResult <Rule>;

            Assert.IsNotNull(response);
            Assert.AreEqual(updatedRule.Index, response.Content.Index);
            Assert.AreEqual(updatedRule.Word, response.Content.Word);
            Assert.AreEqual(updatedRule.RuleType, response.Content.RuleType);

            _repository.AssertWasCalled(x => x.Update(Arg <int> .Is.Anything, Arg <Rule> .Is.Anything));
        }