public async Task TestAddApp()
        {
            List <App> apps   = SetupEmptyAppList();
            App        newApp = Data.Apps.Last();

            await _appRepository.Add(newApp);

            Assert.Contains(newApp, apps);
            VerifyCalledDatabaseSaveChanges();
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Singer,Genre")] Music music)
        {
            if (ModelState.IsValid)
            {
                _context.Add(music);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(music));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Email,RoleId,Username,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public void RepositoryCreateMethod_ShoudSaveInDatabase()
        {
            var itemToAdd = this.GetValidItem("Create");

            var currentRepository = new AppRepository<TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);

            Assert.IsNotNull(itemInDatabase);
            Assert.AreEqual(itemToAdd.Id, itemInDatabase.Id);
        }
Exemple #5
0
        public void RepositoryCreateMethod_ShoudSaveInDatabase()
        {
            var itemToAdd = this.GetValidItem("Create");

            var currentRepository = new AppRepository <TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);

            Assert.IsNotNull(itemInDatabase);
            Assert.AreEqual(itemToAdd.Id, itemInDatabase.Id);
        }
        public void RepositoryUpdateMethod_ShoudUpdateItemInDatabase()
        {
            var itemToAdd = this.GetValidItem("Update");

            var currentRepository = new AppRepository<TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);
            itemInDatabase.Name = "Changed Name";

            currentRepository.Update(itemInDatabase);
            currentRepository.SaveChanges();

            Assert.AreEqual(itemToAdd.Name, itemInDatabase.Name);
        }
        public void RepositoryDeleteMethod_ShoudDeleteItemFromTheDatabase()
        {
            var itemToAdd = this.GetValidItem("Delete");

            var currentRepository = new AppRepository<TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);

            currentRepository.Delete(itemInDatabase);
            currentRepository.SaveChanges();

            var deletedItem = currentRepository.Find(itemToAdd.Id);

            Assert.IsNull(deletedItem);
        }
Exemple #8
0
        public void RepositoryDeleteMethod_ShoudDeleteItemFromTheDatabase()
        {
            var itemToAdd = this.GetValidItem("Delete");

            var currentRepository = new AppRepository <TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);

            currentRepository.Delete(itemInDatabase);
            currentRepository.SaveChanges();

            var deletedItem = currentRepository.Find(itemToAdd.Id);

            Assert.IsNull(deletedItem);
        }
Exemple #9
0
        public void RepositoryUpdateMethod_ShoudUpdateItemInDatabase()
        {
            var itemToAdd = this.GetValidItem("Update");

            var currentRepository = new AppRepository <TestEntity>(this.databaseContext);

            currentRepository.Add(itemToAdd);
            currentRepository.SaveChanges();

            var itemInDatabase = currentRepository.Find(itemToAdd.Id);

            itemInDatabase.Name = "Changed Name";

            currentRepository.Update(itemInDatabase);
            currentRepository.SaveChanges();

            Assert.AreEqual(itemToAdd.Name, itemInDatabase.Name);
        }
 public void Post([FromBody] AppModel value)
 {
     apps.Add(value);
 }
 public void Add(Application application)
 {
     _appRepo.Add(application);
 }