public void AddingMultipleCuries_WhenValid_AddsThemAllToTheCollection() { var model = new SimpleModel(); var graph = new HalGraph(model); var firstCurie = new Curie("a", "/api/some-resource1/{template}"); var secondCurie = new Curie("b", "/api/some-resource2/{template}"); var thirdCurie = new Curie("c", "/api/some-resource3/{template}"); var fourthCurie = new Curie("d", "/api/some-resource4/{template}"); graph.AddCuries(new List <Curie> { firstCurie, secondCurie, thirdCurie, fourthCurie }); var curiesCollection = (List <CurieLink>)((Dictionary <string, object>)graph["_links"])["curies"]; var expectedCurieLink1 = new CurieLink("a", "/api/some-resource1/{template}"); var expectedCurieLink2 = new CurieLink("b", "/api/some-resource2/{template}"); var expectedCurieLink3 = new CurieLink("c", "/api/some-resource3/{template}"); var expectedCurieLink4 = new CurieLink("d", "/api/some-resource4/{template}"); Assert.True(((Dictionary <string, object>)graph["_links"]).Count == 1); Assert.True(curiesCollection.Count == 4); expectedCurieLink1.ShouldDeepEqual(curiesCollection[0]); expectedCurieLink2.ShouldDeepEqual(curiesCollection[1]); expectedCurieLink3.ShouldDeepEqual(curiesCollection[2]); expectedCurieLink4.ShouldDeepEqual(curiesCollection[3]); }
public void AddingMultipleCuries_WithEmptyCuriesCollection_ThrowsException() { var model = new SimpleModel(); var graph = new HalGraph(model); var curiesToAdd = new List <Curie>(); Assert.Throws <ArgumentException>(() => { graph.AddCuries(curiesToAdd); }); }
public void AddingMultipleCuries_WhenValid_ReturnsTheHalGraph() { var model = new SimpleModel(); var graph = new HalGraph(model); var firstCurie = new Curie("a", "/api/some-resource1/{template}"); var secondCurie = new Curie("b", "/api/some-resource2/{template}"); var thirdCurie = new Curie("c", "/api/some-resource3/{template}"); var fourthCurie = new Curie("d", "/api/some-resource4/{template}"); var result = graph.AddCuries(new List <Curie> { firstCurie, secondCurie, thirdCurie, fourthCurie }); Assert.Equal(expected: graph, actual: result); }