Exemplo n.º 1
0
        public void HomeController__GetThings__ReturnsListOfSomething3WithId()
        {
            var mockInteractor = new Mock <ISomething3Interactor>();
            int expectedId     = 1;
            var something3     = new Something3.Core.Model.Something3()
            {
                FullName = "My Pal"
            };

            using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(HomeController__GetThings__ReturnsListOfSomething3WithId)))
            {
                IClassLibraryPersistence persistence = new ClassLibraryPersistence(ctx);
                persistence.SaveSomething3(something3);
            };

            using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(HomeController__GetThings__ReturnsListOfSomething3WithId)))
            {
                IClassLibraryPersistence persistence = new ClassLibraryPersistence(ctx);
                var interactor = new Something3DisplayInteractor(persistence);

                List <Something3WithId> results = interactor.GetThings();
                Equal(something3.FullName, results[0].FullName);
                Equal(expectedId, results[0].Id);
            }
        }
        public void PersistsSomething3()
        {
            var something3 = new Core.Model.Something3()
            {
                FullName = "My Pal"
            };

            using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(PersistsSomething3)))
            {
                IClassLibraryPersistence persistence = new ClassLibraryPersistence(ctx);
                persistence.SaveSomething3(something3);
            };

            using (var ctx = new DbContextFactory().CreateAppDbContext(nameof(PersistsSomething3)))
            {
                var savedSomething3 = ctx.Something3s.Single();
                AreEqual(something3.FullName, savedSomething3.FullName);
            };
        }