예제 #1
0
        public void AddNewRule_ExpectRuleStored()
        {
            _repository.Stub(x => x.Add(Arg <Rule> .Is.Anything));
            _repository.Stub(x => x.CheckExists(Arg <int> .Is.Anything)).Return(false);

            var ruleToAdd = new Rule {
                Index = 8, Word = "boing", RuleType = RuleType.MultipleOf
            };
            var result = _target.AddRule(ruleToAdd);

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

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

            _repository.AssertWasCalled(x => x.Add(Arg <Rule> .Is.Anything));
        }