public void Should_return_module_type_by_id() { using (var context = new WeapsyDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var moduleType = repository.GetById(_moduleTypeId1); Assert.NotNull(moduleType); } }
public void Should_return_null_if_module_type_is_deleted() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var moduleType = repository.GetById(_deletedModuleTypeId); Assert.Null(moduleType); } }
public void Should_save_new_moduleType() { var newModuleType = ModuleTypeFactory.ModuleType(Guid.NewGuid(), "Name 3", "Title 3", "Description 3"); using (var context = new WeapsyDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newModuleType); } using (var context = new WeapsyDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var moduleType = repository.GetById(newModuleType.Id); Assert.NotNull(moduleType); } }
public void Should_update_moduleType() { const string newModuleTypeTitle = "New Title 1"; var moduleTypeToUpdate = ModuleTypeFactory.ModuleType(_moduleTypeId1, "Name 1", newModuleTypeTitle, "Description 1"); using (var context = new WeapsyDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Update(moduleTypeToUpdate); } using (var context = new WeapsyDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedModuleType = repository.GetById(_moduleTypeId1); Assert.AreEqual(newModuleTypeTitle, updatedModuleType.Title); } }