예제 #1
0
        public void AddWordShouldSaveTheRelationship()
        {
            //ARRANGE
            var model = new AddWordViewModel
            {
                Word = new WordEntity {
                    Id = Guid.NewGuid()
                }
            };

            var logic = new Mock <ITopicWordLogic>();

            logic
            .Setup(x => x.Create(It.IsAny <TopicWord>()))
            .Verifiable("Should create the relationship.");

            var controller = new TopicController(null, null, logic.Object, null);

            //ACT
            var result = controller.AddWord(model) as RedirectToRouteResult;

            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
예제 #2
0
        public void AddWordShouldDisplayCorrectView()
        {
            //ARRANGE
            var id = Guid.NewGuid();

            var wordLogic = new Mock <IWordLogic>();

            wordLogic
            .Setup(x => x.GetAll())
            .Returns(new List <WordEntity>())
            .Verifiable("Should get all the word in the system");

            var controller = new TopicController(null, wordLogic.Object, null, null);

            //ACT
            var result = controller.AddWord(id) as ViewResult;

            //ASSERT
            wordLogic.Verify();

            Assert.NotNull(result);
            Assert.NotNull(result.Model);
            Assert.That(result.ViewName, Is.EqualTo("AddWord"));
        }