public void should_append_typename_and_Json_to_file() { var savedCar = new Car("Volvo"); _database.Save(savedCar); Assert.AreEqual(typeof(Car) + ":{\"Brand\":\"Volvo\"}", _streamHandlerAppendStub.AppendedString); }
public void should_append_two_objects_to_file() { var car1 = new Car("Volvo"); var car2 = new Car("SAAB"); _database.Save(car1); _database.Save(car2); Assert.AreEqual(typeof(Car) + ":{\"Brand\":\"SAAB\"}", _streamHandlerAppendStub.AppendedString); }
public void should_save_and_retrieve_same_object_contents() { Car savedCar = new Car("Volvo"); var saveDatabase = new LatteDB(DATABASE_FILENAME); saveDatabase.Save(savedCar); var readDatabase = new LatteDB(DATABASE_FILENAME); var retrievedCar = readDatabase.GetAll<Car>()[0]; Assert.AreEqual(savedCar.Brand, retrievedCar.Brand); }
public void should_save_and_retrieve_objects_of_different_types_in_same_database() { Car savedCar = new Car("Volvo"); Airplane savedPlane = new Airplane("Airbus", "A380"); var saveDatabase = new LatteDB(DATABASE_FILENAME); saveDatabase.Save(savedCar); saveDatabase.Save(savedPlane); var readDatabase = new LatteDB(DATABASE_FILENAME); var retrievedCar = readDatabase.GetAll<Car>()[0]; Assert.AreEqual(savedCar.Brand, retrievedCar.Brand); var retrievedPlane = readDatabase.GetAll<Airplane>()[0]; Assert.AreEqual(savedPlane.Maker, retrievedPlane.Maker); Assert.AreEqual(savedPlane.Model, retrievedPlane.Model); }