예제 #1
0
        public void CallingAdd_On_Repository_AddsEntity_ToUnderlyingDbSet()
        {
            var context = new ShoutOutInMemoryDbContextFactory <ShoutOutContext>()
                          .Create("shoutoutone");

            var shoutOutRepository = new ShoutOutRepository <User>(context);

            shoutOutRepository.Add(_user);

            shoutOutRepository.Save();

            context.Users.Count().ShouldBe(1);
        }
예제 #2
0
        public void Creating_AnewEntity_AssignAnIdId()
        {
            var context = new ShoutOutInMemoryDbContextFactory <ShoutOutContext>()
                          .Create("shoutout");

            var shoutOutRepository = new ShoutOutRepository <User>(context);

            shoutOutRepository.Add(_user);

            shoutOutRepository.Save();

            _user.Id.ShouldNotBeNull();

            shoutOutRepository.GetEntityById(_user.Id).ShouldNotBeNull();
        }
예제 #3
0
        public void CallingDelete_on_Repository_DeletesEntity_FromUnderlyingDbSet()
        {
            var context = new ShoutOutInMemoryDbContextFactory <ShoutOutContext>()
                          .Create("shoutout");

            var shoutOutRepository = new ShoutOutRepository <User>(context);

            shoutOutRepository.Add(_user);

            shoutOutRepository.Save();

            shoutOutRepository.Delete(_user);

            shoutOutRepository.Save();
        }