public void save_and_load_city() { ICity city = CreateTestCity(); // Act Stream stream = BinarySerialization.Serialize(city); stream.Position = 0; ICity city2 = BinarySerialization.Deserialize <ICity>(stream); // Assert city2.Name.Should().BeEquivalentTo(city.Name); city2.FindCompany("C01").Should().NotBeNull(); city2.FindCompany("C02").Should().NotBeNull(); city2.FindCompany("C01").City.Should().BeSameAs(city2); }
public void T1_companies_can_be_found_by_name() { ICity s = CityFactory.CreateCity("Paris"); ICompany c1 = s.AddCompany("SNCF"); s.FindCompany("SNCF").Should().BeSameAs(c1); s.FindCompany("RATP").Should().BeNull(); ICompany c2 = s.AddCompany("RATP"); s.FindCompany("SNCF").Should().BeSameAs(c1); s.FindCompany("RATP").Should().BeSameAs(c2); s.FindCompany("Transports de Lyon").Should().BeNull(); ICompany c3 = s.AddCompany("Transports de Lyon"); ICompany c4 = s.AddCompany("Transports de Marseille"); ICompany c5 = s.AddCompany("Transports de Lille"); s.FindCompany("SNCF").Should().BeSameAs(c1); s.FindCompany("RATP").Should().BeSameAs(c2); s.FindCompany("Transports de Lyon").Should().BeSameAs(c3); s.FindCompany("Transports de Marseille").Should().BeSameAs(c4); s.FindCompany("Transports de Lille").Should().BeSameAs(c5); var randomNames = Enumerable.Range(0, 20).Select(i => String.Format("n°{0} - {1}", i, Guid.NewGuid().ToString())).ToArray(); var teachers = randomNames.Select(n => s.AddCompany(n)).ToArray(); teachers.Should().BeEquivalentTo(randomNames.Select(n => s.FindCompany(n))); }