public void FromAssembly_CachesInstances() { var fakeAssembly = new FakeAssembly(); var expected = ResourceContainer.FromAssembly(fakeAssembly); var actual = ResourceContainer.FromAssembly(fakeAssembly); Assert.Same(expected, actual); }
public void Load_WhenAssemblyDoesNotContainResource_ReturnsNullTextReader() { var fakeAssembly = new FakeAssembly(); var target = ResourceContainer.FromAssembly(fakeAssembly); var actual = target.Load(null); Assert.Same(TextReader.Null, actual); }
public void ZipCodes_MapsPropertiesCorrectly() { var data = ZipCodeHeader + Environment.NewLine + "\"AK\",\"99678\",\"59.17348\",\"-160.71555\",\"996\",\"-9\""; var fakeAssembly = new FakeAssembly(); fakeAssembly.Resources.Add("Ritter.Atlas.Resources.ZipCodes.csv", new MemoryStream(Encoding.UTF8.GetBytes(data))); var fakeResources = ResourceContainer.FromAssembly(fakeAssembly); var target = new GeographyProvider(fakeResources); var actual = target.ZipCodes().Single(); Assert.Equal("99678", actual.Id); }
public void Load_WhenAssemblyContainsResource_DoesNotReturnNullTextReader() { const string ResourceName = "Foobar"; var expected = new MemoryStream(Encoding.ASCII.GetBytes(ResourceName)); var fakeAssembly = new FakeAssembly(); fakeAssembly.Resources.Add(ResourceName, expected); var target = ResourceContainer.FromAssembly(fakeAssembly); var actual = target.Load(ResourceName); Assert.Equal(ResourceName, actual.ReadToEnd()); }
public void ZipCodes_MapsPropertiesCorrectly() { var data = ZipCodeHeader + Environment.NewLine + "NY,00501,40.815400,-73.045600,25,-5 ,HOLTSVILLE"; var fakeAssembly = new FakeAssembly(); fakeAssembly.Resources.Add("Ritter.Atlas.Resources.ZipCodes.csv", new MemoryStream(Encoding.UTF8.GetBytes(data))); var fakeResources = ResourceContainer.FromAssembly(fakeAssembly); var target = new GeographyProvider(fakeResources); var actual = target.ZipCodes().Single(); Assert.Equal("00501", actual.Id); Assert.Equal("NY", actual.StateCode); Assert.Equal(40.815400f, actual.Latitude); Assert.Equal(-73.045600f, actual.Longitude); Assert.Equal(-5, actual.TimeZone); Assert.Equal("HOLTSVILLE", actual.PrimaryCity); }