public void Test1() { var result = HAL.Builder() .WithState(new { Name = "Masoud", Familty = "Bahrami", Age = 25 }) .WithSelfLink("/person/20", HttpVerbs.GET, false) .WithFirstLink("/person/first", HttpVerbs.GET, false) .WithLastLink("/person/last", HttpVerbs.GET, false) .WithLink(new LinkObject("test") { Links = new List <Link> { Link.New("asd").WithQueryParameter(ScalarQueryParameter.NewBoolean("has", 2)) .WithQueryParameter(ScalarQueryParameter.NewNumber("age", 1)) } }) .WithEmbedded(new Embedded("ed:orders") .WithResource(EmbeddedResource.New(masoud) .WithSelfLink("/orders/123", HttpVerbs.GET) .WithLinkObject("basket", "/orders/123", HttpVerbs.GET)) ) .WithEmbedded(new Embedded("ed:saba") .WithResource(EmbeddedResource.New(masoud) .WithSelfLink("/orders/123", HttpVerbs.GET) .WithLinkObject("basket", "/orders/123", HttpVerbs.GET)) ) .Build(); }
public void Shoud_Successfully_Insert_QueryParameters() { //Arrange //Act var sut = Link.NewTRACE("/orders/{id}") .WithQueryParameter(ScalarQueryParameter.NewBoolean("isAdmin", 1)); //Assert Assert.Equal(1, sut.QueryParameters.Count); Assert.Equal("isAdmin", sut.QueryParameters.Single().Title); }
public void Shoud_Raise_Error_When_Inserting_QueryParameter_With_The_Same_Position() { //Arrange //Act //Assert Assert.Throws <LinkQueryParameterPositionDuplicatedException>(() => Link.NewTRACE("/orders/{id}") .WithQueryParameter(ScalarQueryParameter.NewBoolean("isAdmin", 1)) .WithQueryParameter(ScalarQueryParameter.NewNumber("age", 1))); //Arrange var parameters = new List <ScalarQueryParameter> { ScalarQueryParameter.NewBoolean("isAdmin", 1), ScalarQueryParameter.NewBoolean("isAdmin", 1) }; //Act //Assert Assert.Throws <LinkQueryParameterPositionDuplicatedException>(() => Link.NewTRACE("/orders/{id}").WithQueryParameters(parameters) ); }