public void GetPartsForSupplier(int supplierId) { string expectedJsonPath = $"SupplierRepo\\GetPartsForSupplier\\expected{supplierId}.json"; NutsAndBoltsContext context = ContextFactory.GetContext(); SupplierRepo repo = new SupplierRepo(context); List <Part> actual = repo.GetPartsForSupplier(supplierId); List <Part> expected = JToken.Parse(File.ReadAllText(expectedJsonPath)).ToObject <List <Part> >(); string actualJson = actual.ToJsonString(); string expectedJson = expected.ToJsonString(); string sideBySide = FileStringComparer.GetSideBySideFileStrings(expectedJson, actualJson, "EXPECTED", "ACTUAL"); output.WriteLine(sideBySide); Assert.Equal(expectedJson, actualJson); }
public void PartRepoGetById(int id) { var expectedJsonFile = $"PartRepo\\GetById\\expected{id}.json"; NutsAndBoltsContext context = ContextFactory.GetContext(); var repo = new PartRepo(context); Part actual = repo.GetById(id); Part expected = JToken.Parse(File.ReadAllText(expectedJsonFile)).ToObject <Part>(); string actualJson = actual.ToJsonString(); string expectedJson = expected.ToJsonString(); string sideBySide = FileStringComparer.GetSideBySideFileStrings(expectedJson, actualJson, "EXPECTED", "ACTUAL"); output.WriteLine(sideBySide); Assert.Equal(expectedJson, actualJson); }