public void Can_save_an_idea_to_a_database() { //Arrange IDbAdapter database; const string ideaDescription = "test idea"; try { database = SetupDatabase(false); } catch (FieldAccessException faex) { Console.WriteLine(faex.Message); database = SetupDatabase(false); } var repository = new IdeaRepository(database); //Act repository.Create(ideaDescription); //Assert var result = RetrieveIdeaCollectionFromDatabase(database); Assert.NotEmpty(result); }
public void Can_retrieve_an_idea_by_id() { //Arrange var description = "test idea 11"; var testItem = new Idea(description); var repository = new IdeaRepository(new SqlLiteDbIdeaAdapter(ConnectionString, DatabaseName)); //Act var id = repository.Create(description); //Assert var result = repository.Get(id); Assert.Equal(testItem.Description, result.Description); }
public void Should_receive_record_id_after_record_insert() { //Arrange const string ideaDescription = "test idea 10"; var sqlLiteDbAdapter = new SqlLiteDbIdeaAdapter(ConnectionString, DatabaseName); var repository = new IdeaRepository(sqlLiteDbAdapter); //Act int result = repository.Create(ideaDescription); //Assert Assert.IsType <int>(result); }
public void Can_delete_an_idea_from_the_database() { //Arrange const string ideaDescription = "test idea"; var database = SetupDatabase(true); var repository = new IdeaRepository(database); //Act repository.Create(ideaDescription); IList <Idea> resultCheckState = RetrieveIdeaCollectionFromDatabase(database);; Assert.NotEmpty(resultCheckState); repository.Delete(resultCheckState[0].Id); //Assert IEnumerable result = RetrieveIdeaCollectionFromDatabase(database);; Assert.Empty(result); }