public void ShouldOrderByLevel(string orderDirection)
        {
            var fakeContext = new FakeContext("OrderByLevel");

            fakeContext.FillWith <Error>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var service  = new ErrorRepository(context);
                var actual   = service.OrderByLevel(service.GetAll(), orderDirection).ToList();
                var expected = new List <Error>();

                if (orderDirection == "descending")
                {
                    expected = fakeContext.GetFakeData <Error>().OrderByDescending(x => x.LevelId).ToList();
                    Assert.Equal(expected, actual, new ErrorIdComparer());
                }

                else
                {
                    expected = fakeContext.GetFakeData <Error>().OrderBy(x => x.LevelId).ToList();
                    Assert.Equal(expected, actual, new ErrorIdComparer());
                }
            }
        }
 public void FillWith <T>() where T : class
 {
     using (var context = new CentralErrosContext(FakeOptions))
     {
         if (context.Set <T>().Count() == 0)
         {
             foreach (T item in GetFakeData <T>())
             {
                 context.Set <T>().Add(item);
             }
             context.SaveChanges();
         }
     }
 }
        public void ShouldAddNewWhenSave()
        {
            var fakeContext = new FakeContext("AddWhenSave");
            var data        = fakeContext.GetFakeData <User>().First();

            data.Id = 0;

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var service = new UserRepository(context);
                service.Save(data);

                Assert.NotEqual(0, context.Users.First().Id);
            }
        }
        public void ShouldGetAll()
        {
            var fakeContext = new FakeContext("GetAll");

            fakeContext.FillWith <Error>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Error>();
                var service  = new ErrorRepository(context);
                var actual   = service.GetAll();

                Assert.Equal(expected, actual, new ErrorIdComparer());
            }
        }
Esempio n. 5
0
        public void ShouldRemoveById(int id)
        {
            var fakeContext = new FakeContext("RemoveById");

            fakeContext.FillWith <Level>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var data = fakeContext.GetFakeData <Level>();

                var service = new LevelRepository(context);
                service.Remove(id);

                Assert.Equal(data.Count - 1, context.Levels.Count());
            }
        }
        public void ShouldUpdate()
        {
            var fakeContext = new FakeContext("ShouldUpdate");

            fakeContext.FillWith <Error>();
            var data = fakeContext.GetFakeData <Error>().FirstOrDefault();

            data.Details = "";

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var service = new ErrorRepository(context);
                service.Update(data);
                var actual = context.Errors.Where(x => x.Id == data.Id).SingleOrDefault();

                Assert.Equal(data, actual, new DetailsErrorComparer());
            }
        }
        public void ShouldFindByStatus(char status)
        {
            var fakeContext = new FakeContext("FindByStatus");

            fakeContext.FillWith <Error>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Error>()
                               .Where(x => x.Status == status);

                var service = new ErrorRepository(context);

                var actual = service.FindByStatus(status);

                Assert.Equal(expected, actual, new ErrorIdComparer());
            }
        }
        public void ShouldFindById(int id)
        {
            var fakeContext = new FakeContext("FindById");

            fakeContext.FillWith <Error>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var expected = context.Errors.
                               Where(x => x.Id == id).
                               SingleOrDefault();

                var service = new ErrorRepository(context);
                var actual  = service.GetById(id);

                Assert.Equal(expected, actual, new ErrorIdComparer());
            }
        }
        public void ShouldRemove()
        {
            var fakeContext = new FakeContext("ShouldRemove");

            fakeContext.FillWith <Error>();
            var data = fakeContext.GetFakeData <Error>().First();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Error>().Count() - 1;

                var service = new ErrorRepository(context);
                service.Remove(data);

                var actual = context.Errors.Count();

                Assert.Equal(expected, actual);
            }
        }
        public void ShouldChangeStatus(int id)
        {
            var fakeContext = new FakeContext("ChangeStatus");

            fakeContext.FillWith <Error>();

            using (var context = new CentralErrosContext(fakeContext.FakeOptions))
            {
                var actual = fakeContext.GetFakeData <Error>().Find(x => x.Id == id);

                var error = context.Errors
                            .Where(x => x.Id == id)
                            .SingleOrDefault();

                var service = new ErrorRepository(context);
                service.ChangeStatus(error);

                Assert.NotEqual(actual.Status, error.Status);
            }
        }
Esempio n. 11
0
 public LevelRepository(CentralErrosContext context) : base(context)
 {
 }
 public EnvironmentRepository(CentralErrosContext context) : base(context)
 {
 }
 public ApplicationLayerRepository(CentralErrosContext context) : base(context)
 {
 }
Esempio n. 14
0
 public UserServiceTest()
 {
     _baseContext = new BaseContext();
     _context     = new CentralErrosContext(_baseContext.Options);
     _userService = new UserService(_context);
 }
Esempio n. 15
0
 public LogService(CentralErrosContext context)
 {
     _context = context;
 }
 public LanguageRepository(CentralErrosContext context) : base(context)
 {
 }
 public EventServiceTest()
 {
     _baseContext  = new BaseContext();
     _context      = new CentralErrosContext(_baseContext.Options);
     _eventService = new EventService(_context);
 }
Esempio n. 18
0
 public UserService(CentralErrosContext context)
 {
     _context = context;
 }
Esempio n. 19
0
 public EventService(CentralErrosContext context)
 {
     _context = context;
 }
Esempio n. 20
0
 public BaseRepository(CentralErrosContext context)
 {
     _context = context;
 }
 public UserRepository(CentralErrosContext context)
 {
     _context = context;
 }