示例#1
0
        public void SaveWithoutIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider);

            genreBE.New();
            genreBE.Name = "TestGenreName";
            genreBE.Save();

            Assert.IsTrue(genreBE.Id != default);
        }
示例#2
0
        public void SaveValidIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var genre   = new Genre
            {
                GenreId = 1
            };

            context.Add(genre);
            context.SaveChanges();

            GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider);

            genreBE.Load(1);
            genreBE.Name = "TestGenreName";
            genreBE.Save();

            GenreBE genreBE2 = new GenreBE(cRUDTestDBContextProvider);

            genreBE2.Load(1);
            Assert.IsTrue(genreBE2.Id == 1);
            Assert.IsTrue(genreBE2.Name == "TestGenreName");
        }