Exemplo n.º 1
0
        public void Delete_existingModel_shouldRemoveModel()
        {
            var newApp = CreateApp();
            var mockRepository = new Mock<IAppRepository>();
            var controller = new AppController {AppRepository = mockRepository.Object};

            controller.Delete(newApp.Id.Value);

            mockRepository.Verify(x => x.Delete(newApp.Id.Value));
        }
Exemplo n.º 2
0
        public void Post_validModel_shouldInsertModel()
        {
            var newApp = CreateApp();
            var mockRepository = new Mock<IAppRepository>();
            var controller = new AppController {AppRepository = mockRepository.Object};

            controller.Post(newApp);

            mockRepository.Verify(x => x.Insert(newApp));
        }
Exemplo n.º 3
0
        public void Get_appExists_shouldReturnApp()
        {
            var expected = CreateApp();
            var mockRepository = new Mock<IAppRepository>();
            mockRepository.Setup(x => x.Get(expected.Id.Value)).Returns(expected);
            var controller = new AppController {AppRepository = mockRepository.Object};

            var actual = controller.Get(expected.Id.Value);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void Get_allAppsExist_shouldReturnApps()
        {
            var expected = CreateApp();
            var mockRepository = new Mock<IAppRepository>();
            mockRepository.Setup(x => x.GetAll()).Returns(new[]{ expected, expected }.ToList());
            var controller = new AppController {AppRepository = mockRepository.Object};

            var actual = controller.Get();

            Assert.AreEqual(expected, actual.First());
        }