コード例 #1
0
        public void CreateReturnViewIsOk()
        {
            //
            var controller = new PozoController(null, null, null);
            //
            var view = controller.Create();

            Assert.IsInstanceOf(typeof(ViewResult), view);
            Assert.AreEqual("Create", view.ViewName);
        }
コード例 #2
0
        public void ShareReturnViewIsOk()
        {
            var id = 1;
            var mockRepository = new Mock<IPozoRepository>();

            mockRepository.Setup(o => o.Find(id)).Returns(new Pozo { });

            var controller = new PozoController(mockRepository.Object, null, null);

            var view = controller.Share(id);

            Assert.IsInstanceOf(typeof(ViewResult), view);
            Assert.AreEqual("Share", view.ViewName);
            Assert.IsInstanceOf(typeof(Pozo), view.Model);
        }
コード例 #3
0
        public void ShareIsOk()
        {
            var id = 1;

            var mockRepository = new Mock<IPozoRepository>();
            var mockMail = new Mock<IMailerService>();

            mockRepository.Setup(o => o.Find(id)).Returns(new Pozo { });

            var controller = new PozoController(mockRepository.Object, null, mockMail.Object);

            var view = controller.Share(id, 1, "*****@*****.**", "lorem ipsum");

            Assert.IsInstanceOf(typeof(RedirectToRouteResult), view);
        }
コード例 #4
0
        public void PostCreateSaveNewPozo()
        {
            var pozo = new Pozo();

            var mockRepository = new Mock<IPozoRepository>();
            var mockValidator = new Mock<IPozoValidator>();

            mockValidator.Setup(o => o.Pass(pozo)).Returns(true);

            var controller = new PozoController(mockRepository.Object, mockValidator.Object, null);

            var redirect = controller.Create(pozo);

            Assert.IsInstanceOf(typeof(RedirectToRouteResult), redirect);

            mockRepository.Verify(o => o.Save(pozo), Times.Once());
        }