Esempio n. 1
0
        public void index_should_return_key_model_list()
        {
            // Arrange
            var demoService = new Mock<IDemoDataService>();
            var list = new List<KeyModel> { new KeyModel { Key = "my-key" } };
            demoService.Setup(x => x.GetMyKeys()).Returns(list);

            // Act
            var controller = new TagController(null, demoService.Object);
            var view = controller.Index();

            // Assert
            Assert.NotNull(view);

            var model = view.Model as List<KeyModel>;
            Assert.NotNull(model);

            demoService.Verify(x => x.GetMyKeys(), Times.Once);

            CollectionAssert.AllItemsAreUnique(model);
            Assert.AreEqual(model.Count, list.Count);
        }
Esempio n. 2
0
        public void index_should_return_key_model_list()
        {
            // Arrange
            var demoService = new Mock<IDemoDataService>();
            var list = new List<KeyModel> { new KeyModel { Key = "my-key" } };
            demoService.Setup(x => x.GetMyKeys()).Returns(list);

            // Act
            var controller = new TagController(null, demoService.Object);
            var view = controller.Index();

            // Assert
            Assert.NotNull(view);

            var model = view.Model as List<KeyModel>;
            Assert.NotNull(model);

            demoService.Verify(x => x.GetMyKeys(), Times.Once);

            CollectionAssert.AllItemsAreUnique(model);
            Assert.AreEqual(model.Count, list.Count);
            Assert.IsTrue(controller.HasGetAttribute("Index", new[] { typeof(List<KeyModel>) }), "HttpGet attribute not found on TagController's Index() action method");
        }
Esempio n. 3
0
        public void detail_should_return_key_model_list()
        {
            // Arrange
            var tagService = new Mock<ITagService>();
            var list = new List<WordModel> { new WordModel { Key = "my-key" } };
            tagService.Setup(x => x.GetWords(""));

            // Act
            var controller = new TagController(null, null, null);
            var view = controller.Detail();

            // Assert
            Assert.NotNull(view);
            var model = view.Result.Model as List<WordModel>;

            Assert.NotNull(model);

            CollectionAssert.AllItemsAreUnique(model);
            Assert.AreEqual(model.Count, list.Count);

            tagService.Verify(x => x.GetWords(""), Times.Once);
            controller.AssertGetAttribute("Index", new[] { typeof(string) });
        }