Пример #1
0
        public void AddRangeStateTest()
        {
            //country table must NOT be Empty
            var           context   = new ApplicationDbContext();
            var           target    = new StateRepository(context);
            var           countryId = context.Country.FirstOrDefault().Id;//select first row from Country Table, For Country id
            IList <State> stateList = new List <State>();
            var           state1    = new State()
            {
                CountryId = countryId, Title = "Gilan"
            };
            var state2 = new State()
            {
                CountryId = countryId, Title = "Tehran"
            };

            stateList.Add(state1);
            stateList.Add(state2);
            var expected = context.State.Count() + stateList.Count;

            target.AddRange(stateList);
            target.Complete();
            var actual = context.State.Count();

            Assert.AreEqual(expected, actual);//if expected equals to actual then the test would pass
        }
Пример #2
0
        public void UpdateSingleModelStateTest()
        {//State Table Must Not be Empty
            var context = new ApplicationDbContext();
            var state   = context.State.FirstOrDefault();
            var target  = new StateRepository(context);

            state.Title = Guid.NewGuid().ToString();
            target.Update(state);
            target.Complete();
            var actual = target.Get(state.Id);

            Assert.AreEqual(state.Title, actual.Title);
        }
Пример #3
0
        public void RemoveRangeStateTest()
        {
            //State Table Must not Be Empty
            var           context   = new ApplicationDbContext();
            var           target    = new StateRepository(context);
            IList <State> stateList = target.GetAll().ToList();

            target.RemoveRange(stateList);
            target.Complete();
            var count = context.State.Count();

            Assert.AreEqual(count, 0);//if expected equals to actual then the test would pass
        }
Пример #4
0
        public void RemoveSingleModelStateTest()
        {//State Table Must Not be Empty
            var   context  = new ApplicationDbContext();
            State state    = context.State.FirstOrDefault();
            int   expected = context.State.Count() - 1;
            var   target   = new StateRepository(context);

            target.Remove(state);
            target.Complete();
            int actual = context.State.Count();

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void AddSingleModelStateTest()
        {
            //country table must NOT be Empty
            var context   = new ApplicationDbContext();
            var expected  = context.State.Count() + 1;
            var target    = new StateRepository(context);
            var countryId = context.Country.FirstOrDefault().Id;//select first row from Country Table, For Country id
            var state     = new State()
            {
                CountryId = countryId, Title = "Rasht"
            };

            target.Add(state);
            target.Complete();
            var actual = context.State.Count();

            Assert.AreEqual(expected, actual);//if expected equals to actual then the test would be passed
        }