예제 #1
0
      public void RemoveRangeCountryTest()
      {
          var             context   = new ApplicationDbContext();
          var             target    = new CountryRepository(context);
          IList <Country> countries = target.GetAll().ToList();

          target.RemoveRange(countries);
          target.Complete();
          var count = context.Country.Count();

          Assert.AreEqual(count, 0);  //if expected equals to actual then the test would pass
      }
예제 #2
0
      public void UpdateCountryTest()
      {
          var context = new ApplicationDbContext();
          var country = context.Country.FirstOrDefault();
          var target  = new CountryRepository(context);

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

          Assert.AreEqual(actual.Title, country.Title);
      }
예제 #3
0
      public void RemoveSingleModelCountryTest()
      {
          var context      = new ApplicationDbContext();
          var target       = new CountryRepository(context);
          var dataToRemove = context.Country.FirstOrDefault();
          int expected     = context.Country.Count() - 1;

          target.Remove(dataToRemove);
          target.Complete();
          int actual = context.Country.Count();

          Assert.AreEqual(actual, expected);
      }
예제 #4
0
      public void AddSingleModelCountryTest()
      {
          var context  = new ApplicationDbContext();
          var expected = context.Country.Count() + 1;
          var target   = new CountryRepository(context);
          var country  = new Country()
          {
              Title = Guid.NewGuid().ToString()
          };

          target.Add(country);
          target.Complete();
          var actual = context.Country.Count();

          Assert.AreEqual(expected, actual);
      }