public void GetRequired_Does_Not_Throw_If_Present() { // arrange const string key = "SomeId"; var value = Guid.NewGuid(); var querySet = new QuerySet { Filters = new List <FilterQuery> { new FilterQuery(key, value.ToString(), "eq") } }; _contextMock.Setup(c => c.QuerySet).Returns(querySet); var service = new QueryAccessor(_contextMock.Object, _loggerMock.Object); // act var result = service.GetRequired <Guid>("SomeId"); // assert Assert.Equal(value, result); }
public void GetRequired_Throws_If_Not_Present() { // arrange const string key = "SomeId"; var value = Guid.NewGuid(); var querySet = new QuerySet { Filters = new List <FilterQuery> { new FilterQuery(key, value.ToString(), "eq") } }; _contextMock.Setup(c => c.QuerySet).Returns(querySet); var service = new QueryAccessor(_contextMock.Object, _loggerMock.Object); // act var exception = Assert.Throws <JsonApiException>(() => service.GetRequired <Guid>("Invalid")); // assert Assert.Equal(422, exception.GetStatusCode()); }