public void ShouldAddDriverByName()
        {
            //arrange
            var context = new InMemoryDataContext();
            var service = new DriversEducationService(new Repository(context));

            //act
            service.AddDriver("Devlin");

            //assert
            context.AsQueryable<Driver>().Count(x => x.LastName == "Devlin").Should().Be(1);
        }
예제 #2
0
        public void ShouldAddDriverByName()
        {
            //arrange
            var context = new InMemoryDataContext();
            var service = new DriversEducationService(new Repository(context));

            //act
            service.AddDriver("Devlin");
            context.Commit();

            //assert
            context.AsQueryable <Driver>().Count(x => x.LastName == "Devlin").Should().Be(1);
        }
        public void ShouldPopulateBackReferenceCollections()
        {
            // Arrange
            var context = new InMemoryDataContext();
            var blog = new Blog();
            var post = new Post { Blog = blog };
            context.Add(post);
            context.Commit();

            // Act
            var fetchedBlog = context.AsQueryable<Blog>().First();

            // Assert
            fetchedBlog.Posts.Count().Should().Be(1);
        }
        public void ShouldPopulateBackReferenceCollections()
        {
            // Arrange
            var context = new InMemoryDataContext();
            var blog    = new Blog();
            var post    = new Post {
                Blog = blog
            };

            context.Add(post);
            context.Commit();

            // Act
            var fetchedBlog = context.AsQueryable <Blog>().First();

            // Assert
            fetchedBlog.Posts.Count().Should().Be(1);
        }
        public void ShouldPopulateBackReferenceSingleProperty()
        {
            // Arrange
            var context = new InMemoryDataContext();
            var blog = new Blog()
            {
                Posts = new List<Post>()
                {
                    new Post()
                }
            };
            context.Add(blog);
            context.Commit();

            // Act
            var fetchedPost = context.AsQueryable<Post>().First();

            // Assert
            fetchedPost.Blog.Should().NotBeNull();
        }
        public void ShouldPopulateBackReferenceSingleProperty()
        {
            // Arrange
            var context = new InMemoryDataContext();
            var blog    = new Blog()
            {
                Posts = new List <Post>()
                {
                    new Post()
                }
            };

            context.Add(blog);
            context.Commit();

            // Act
            var fetchedPost = context.AsQueryable <Post>().First();

            // Assert
            fetchedPost.Blog.Should().NotBeNull();
        }
        public void Add_ShouldStoreASite()
        {
            //arrange
            var item = new Site();

            //act
            _context.Add(item);
            _context.Commit();

            //assert
            Site site = _context.AsQueryable <Site>().First();

            site.Should().BeSameAs(item);
        }