Exemplo n.º 1
0
        public void RemoveCommandPersonNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "RemoveCommandItemNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Author {
                    Id = 1, FirstName = "stokata", LastName = "malinin"
                });
                dc.AddEntity(new Author {
                    Id = 2, FirstName = "enizkata", LastName = "hasan"
                });

                var input = new StringReader("remove author\nstokata\nmalinin\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual(1, dc.GetEntries <Author>().Count);
                Assert.AreEqual("enizkata", dc.GetEntries <Author>()[0].FirstName);
            }
        }
Exemplo n.º 2
0
        public void AddEntityCheckPersonException()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "AddEntityCheckPersonExceptionDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                var input = new StringReader("");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                dc.AddEntity(new User {
                    Id = 1, FirstName = "PakHakvam", LastName = "Nasa"
                });
                dc.AddEntity(new User {
                    Id = 2, FirstName = "PakHakvam", LastName = "Nasa"
                });

                Assert.AreEqual("PakHakvam Nasa is already present in the database\r\n", output.ToString());
            }
        }
Exemplo n.º 3
0
        public void GenericUtilsFindPersonEntityNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "FindPersonEntityNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new User()
                {
                    Id = 1, FirstName = "Hakvam", LastName = "Nasa"
                });

                var input = new StringReader("stokata\nmalinin\nHakvam\nNasa");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                User userFound   = GenericUtil.FindEntity <User>(dc);
                User useOriginal = dc.GetEntryById <User>(1);

                Assert.AreEqual(userFound.Id, useOriginal.Id);
                Assert.AreEqual(userFound.FirstName, useOriginal.FirstName);
                Assert.AreEqual(userFound.LastName, useOriginal.LastName);
                Assert.AreNotEqual(userFound, useOriginal);
            }
        }
Exemplo n.º 4
0
        public void DelitingNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "DelitingNoExceptionsDB")
                          .Options;

            IQueryable <Genre> data = new List <Genre>()
            {
                new Genre {
                    Id = 1, Name = "g1"
                },
                new Genre {
                    Id = 2, Name = "g2"
                },
                new Genre {
                    Id = 3, Name = "g3"
                },
            }.AsQueryable();

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                data.ToList().ForEach(g => dc.AddEntity(g));
                Genre g = dc.GetEntryById <Genre>(1);

                dc.RemoveEntity(g);
            }
        }
Exemplo n.º 5
0
        public void UserBuyingMagazineInsufficientAccessLevel()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "        public void UserBuyingMagazineInsufficientAccessLevelDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Market {
                    Id = 1, Name = "cheren"
                });
                dc.AddEntity(new Magazine {
                    Id = 1, Name = "m1", AccsessLevel = 10, Price = 1
                });
                dc.AddEntity(new User {
                    Id = 1, FirstName = "stokata", LastName = "malinin", AcessLevel = 1, Balance = 10
                });

                try
                {
                    query.UserBuyMagazine(dc.GetEntryById <User>(1), dc.GetEntryById <Magazine>(1), dc.GetEntryById <Market>(1));
                }
                catch (InsufficientAccessLevel e)
                {
                    Assert.Pass();
                    return;
                }
            }

            Assert.Fail();
        }
Exemplo n.º 6
0
        public void UpdateAuthorNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateAuthorNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Author {
                    Id = 1, FirstName = "Maxim", LastName = "Maximov"
                });
                dc.AddEntity(new Author {
                    Id = 2, FirstName = "Pencho", LastName = "Slaveikov"
                });

                var input = new StringReader("update author\nPencho\nSlaveikov\nPetko\n-1\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual(2, dc.GetEntries <Author>().Count);
                Assert.AreEqual("Petko", dc.GetEntries <Author>()[1].FirstName);
                Assert.AreEqual("Slaveikov", dc.GetEntries <Author>()[1].LastName);
            }
        }
Exemplo n.º 7
0
        public void GettingGenresByName()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "GettingGenresByNameDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Genre {
                    Id = 1, Name = "g1"
                });
                dc.AddEntity(new Genre {
                    Id = 2, Name = "g2"
                });
                dc.AddEntity(new Genre {
                    Id = 3, Name = "g3"
                });

                Assert.AreEqual(new List <int> {
                    1
                }, query.GetGenresByName("g1").Select(g => g.Id).ToList());
            }
        }
Exemplo n.º 8
0
        public void GettingMagazinesOverAccessLevel()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "GettingMagazinesOverAccessLevelDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Magazine {
                    Id = 1, Name = "m1", AccsessLevel = 1
                });
                dc.AddEntity(new Magazine {
                    Id = 4, Name = "m2", AccsessLevel = 2
                });
                dc.AddEntity(new Magazine {
                    Id = 2, Name = "m3", AccsessLevel = 3
                });
                dc.AddEntity(new Magazine {
                    Id = 3, Name = "m4", AccsessLevel = 4
                });

                Assert.AreEqual(new List <int> {
                    3
                }, query.GetMagazinesOverAccessLevel(3).Select(m => m.Id).ToList());
            }
        }
Exemplo n.º 9
0
        public void GettingAllEntities()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "GettingAllEntitiesDB")
                          .Options;

            IQueryable <Genre> data = new List <Genre>()
            {
                new Genre {
                    Id = 1, Name = "g1"
                },
                new Genre {
                    Id = 2, Name = "g2"
                },
                new Genre {
                    Id = 3, Name = "g3"
                },
            }.AsQueryable();

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                data.ToList().ForEach(g => dc.AddEntity(g));
                Assert.AreEqual(data.ToList(), dc.GetEntries <Genre>());
            }
        }
Exemplo n.º 10
0
        public void UpdateGenreNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateGenreNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Genre {
                    Id = 1, Name = "soc"
                });

                var input = new StringReader("update genre\nsoc\nmon\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual(1, dc.GetEntries <Genre>().Count);
                Assert.AreEqual("mon", dc.GetEntries <Genre>()[0].Name);
            }
        }
Exemplo n.º 11
0
        public void GettingAuthorsByBothNames()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "GettingAuthorsByBothNamesDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Author {
                    Id = 1, FirstName = "f1", LastName = "l1"
                });
                dc.AddEntity(new Author {
                    Id = 2, FirstName = "f2", LastName = "l2"
                });
                dc.AddEntity(new Author {
                    Id = 3, FirstName = "f3", LastName = "l3"
                });
                Assert.AreEqual(new List <int>()
                {
                    2
                }, query.GetAuthorsByBothNames("f2", "l2").Select(u => u.Id).ToList());
            }
        }
Exemplo n.º 12
0
        public void UpdateMarketNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateMarketNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Market {
                    Id = 1, Name = "cheren"
                });
                dc.AddEntity(new Market {
                    Id = 2, Name = "v dimitrovgrad"
                });

                var input = new StringReader("update market\ncheren\nbyal\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual(2, dc.GetEntries <Market>().Count);
                Assert.AreEqual("byal", dc.GetEntries <Market>()[0].Name);
            }
        }
Exemplo n.º 13
0
        public void UpdateMarketEntityAlreadyContained()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateMarketEntityAlreadyContainedDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Market {
                    Id = 1, Name = "cheren"
                });
                dc.AddEntity(new Market {
                    Id = 2, Name = "byal"
                });

                var input = new StringReader("update market\ncheren\nbyal\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual("$: Name: NewName: byal is already present in the database\r\n$: ", output.ToString());
            }
        }
Exemplo n.º 14
0
        public void UpdateUserEntityAlreadyContained()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateUserEntityAlreadyContainedDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new User {
                    Id = 1, FirstName = "Maxim", LastName = "Maximov"
                });
                dc.AddEntity(new User {
                    Id = 2, FirstName = "Vanya", LastName = "Vlashinska"
                });

                var input = new StringReader("update user\nMaxim\nMaximov\n-1\n-1\nVanya\nVlashinska\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual("$: FirstName: LastName: NewAcessLevel: NewBalance: NewFirstName: NewLastName: Vanya Vlashinska is already present in the database\r\n$: ", output.ToString());
            }
        }
Exemplo n.º 15
0
        public void FindItemEntityNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "FindItemEntityNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Genre()
                {
                    Id = 1, Name = "genre1"
                });

                var input = new StringReader("stokata\ngenre1");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                Genre genreFound    = GenericUtil.FindEntity <Genre>(dc);
                Genre genreOriginal = dc.GetEntryById <Genre>(1);

                Assert.AreEqual(genreFound.Id, genreOriginal.Id);
                Assert.AreEqual(genreFound.Name, genreOriginal.Name);
                Assert.AreNotEqual(genreFound, genreOriginal);
            }
        }
Exemplo n.º 16
0
        public void AddCommandUserNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "AddCommandUserNoExceptionsDB")
                          .Options;

            IQueryable <User> data = new List <User>()
            {
                new User {
                    Id = 1, AcessLevel = 69, Balance = 420, FirstName = "stokata", LastName = "malinin"
                },
                new User {
                    Id = 2, AcessLevel = 420, Balance = 69, FirstName = "enizkata", LastName = "hasan"
                },
            }.AsQueryable();

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                string inputString = "";
                foreach (User u in data.ToList())
                {
                    inputString += $"add user\n{u.AcessLevel}\n{u.Balance}\n{u.FirstName}\n{u.LastName}\n";
                }
                inputString += "exit\n";

                var input = new StringReader(inputString);
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                List <User> l = dc.GetEntries <User>();

                for (int i = 0; i < l.Count; i++)
                {
                    Assert.AreEqual(data.ToList()[i].FirstName, l[i].FirstName);
                    Assert.AreEqual(data.ToList()[i].LastName, l[i].LastName);
                    Assert.AreEqual(data.ToList()[i].AcessLevel, l[i].AcessLevel);
                    Assert.AreEqual(data.ToList()[i].Balance, l[i].Balance);
                }
            }
        }
Exemplo n.º 17
0
        public void AddCommandItemNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "AddCommandItemNoExceptionsDB")
                          .Options;

            IQueryable <Genre> data = new List <Genre>()
            {
                new Genre {
                    Name = "malki detsa"
                },
                new Genre {
                    Name = "golemi detsa"
                },
            }.AsQueryable();

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                string inputString = "";
                foreach (Genre g in data.ToList())
                {
                    inputString += $"add genre\n{g.Name}\n";
                }
                inputString += "exit\n";

                var input = new StringReader(inputString);
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                List <Genre> l = dc.GetEntries <Genre>();
                Assert.AreEqual(data.ToList()[0].Name, l[0].Name);
                Assert.AreEqual(data.ToList()[1].Name, l[1].Name);
            }
        }
Exemplo n.º 18
0
        public void CheckIfTableIsEmpty()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "CheckIfTableIsEmptyDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new Genre {
                    Id = 1, Name = "g"
                });
                Assert.AreEqual(false, query.IsTableEmpty <Genre>());
                Assert.AreEqual(true, query.IsTableEmpty <User>());
                Assert.AreEqual(true, query.IsTableEmpty <Author>());
                Assert.AreEqual(true, query.IsTableEmpty <Magazine>());
            }
        }
Exemplo n.º 19
0
        public void GenericUtilsAddGenreEntityNoExceptionsNoChanging()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "GenericUtilsAddGenreEntityNoExceptionsNoChangingDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                var input = new StringReader("soc\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                Genre g = GenericUtil.CreateObject(new Genre());
                Assert.AreEqual("soc", g.Name);
            }
        }
Exemplo n.º 20
0
        public void BasicTest()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "BasicTestDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new User {
                    Id = 1, FirstName = "Stokata"
                });
                dc.AddEntity(new User {
                    Id = 2, FirstName = "Enizkata"
                });

                Assert.AreEqual(2, dc.GetEntries <User>().Count);
            }
        }
Exemplo n.º 21
0
        public void AddingEntityToDatabaseWithoutExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "AddingEntityToDatabaseWithoutExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new User {
                    Id = 1, FirstName = "first", LastName = "last"
                });
                dc.AddEntity(new Genre {
                    Id = 1, Name = "name"
                });

                Assert.AreEqual("first", dc.GetEntries <User>()[0].FirstName);
                Assert.AreEqual("name", dc.GetEntries <Genre>()[0].Name);
            }
        }
Exemplo n.º 22
0
        public void UpdateEntityMatchingException()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateEntityMatchingExceptionDB")
                          .Options;

            IQueryable <Genre> data = new List <Genre>()
            {
                new Genre {
                    Id = 1, Name = "g1"
                },
                new Genre {
                    Id = 2, Name = "g2"
                },
                new Genre {
                    Id = 3, Name = "g3"
                },
            }.AsQueryable();

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                data.ToList().ForEach(g => dc.AddEntity(g));
                Genre g = dc.GetEntryById <Genre>(1);

                var input = new StringReader("");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                g.Name = "g2";
                dc.UpdateEntry(g);

                Assert.AreEqual("g2 is already present in the database\r\n", output.ToString());
            }
        }
Exemplo n.º 23
0
        public void RemoveCommandPersonEmptyTable()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "RemoveCommandPersonEmptyTableDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                var input = new StringReader("remove author\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual("$: Impossible command!\r\nThere are no entries in the table\r\n$: ", output.ToString());
            }
        }
Exemplo n.º 24
0
        public void AddCommandItemEntityAlreadyContained()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "AddCommandItemEntityAlreadyContainedDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                var input = new StringReader("add genre\nmon\nadd genre\nmon\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual("$: NewName: $: NewName: mon is already present in the database\r\n$: ", output.ToString());
            }
        }
Exemplo n.º 25
0
        public void UpdateUserNoExceptions()
        {
            var options = new DbContextOptionsBuilder <ForbiddenBooksContext>()
                          .UseInMemoryDatabase(databaseName: "UpdateUserNoExceptionsDB")
                          .Options;

            using (ForbiddenBooksContext context = new ForbiddenBooksContext(options))
            {
                DataController dc    = new DataController(context);
                DbQuery        query = new DbQuery(dc);

                dc.AddEntity(new User {
                    Id = 1, FirstName = "Nadya", LastName = "Koleva", AcessLevel = 69, Balance = 420
                });
                dc.AddEntity(new User {
                    Id = 2, FirstName = "Yoanko", LastName = "Mihailova"
                });
                dc.AddEntity(new User {
                    Id = 3, FirstName = "Stokata", LastName = "Malinin"
                });

                var input = new StringReader("update user\nNadya\nKoleva\n420\n-1\n-1\nVulkova\nexit\n");
                Console.SetIn(input);

                var output = new StringWriter();
                Console.SetOut(output);

                UserInputHandler uih = new UserInputHandler(dc);
                uih.ReadInput();

                Assert.AreEqual(3, dc.GetEntries <User>().Count);
                Assert.AreEqual("Nadya", dc.GetEntries <User>()[0].FirstName);
                Assert.AreEqual("Vulkova", dc.GetEntries <User>()[0].LastName);
                Assert.AreEqual(420, dc.GetEntries <User>()[0].AcessLevel);
                Assert.AreEqual(420, dc.GetEntries <User>()[0].Balance);
            }
        }