public void Constructor_FileAlreadyExists_LoadsData() { var listOfCustomers = new List<Customer>(); for (int i = 0; i < MultipleCustomerNum; i++) listOfCustomers.Add(CreateCustomer()); SereializeCustomersToPath(listOfCustomers); repository = CreateRepository(); AssertAreEqual(repository.GetAllCustomers(), listOfCustomers); }
public void Constructor_InvalidPath_ThrowsArgumentException() { repository = CreateRepository("this is a bad path!"); }
public void Constructor_DirectoryDoesntExist_CreatesFile() { dataPath = Path.GetTempPath() + GenString() + @"\" + GenString(); Assert.IsFalse(Directory.Exists(dataPath)); repository = CreateRepository(); Assert.True(File.Exists(dataPath)); }
public async void Constructor_DirectoryExistsFileDoesnt_CreatesFile() { dataPath = Path.GetTempPath() + GenString(); CreateDirectory(dataPath); await (Task.Run(() => repository = CreateRepository())); Assert.True(File.Exists(dataPath)); }
public void PersistCustomer_ValidExistingCustomer_UpdatesCustomer() { const int CustomerId = 5; Customer customerToPersist = CreateCustomer(); customerToPersist.Id = CustomerId; SereializeCustomersToPath(new List<Customer> {customerToPersist}); repository = CreateRepository(); customerToPersist = CreateCustomer(); customerToPersist.Id = CustomerId; repository.PersistCustomer(customerToPersist); Assert.IsTrue(customerToPersist.HasMatchingState(GetAllPersistedCustomers().First())); }