public void Constructor_CreatesEmptyList_WhenNoClassificationsAreGiven() { var dut = new GetAllDisciplinesQuery("PCS$TESTPLANT", null); Assert.IsNotNull(dut.Classifications); Assert.AreEqual(0, dut.Classifications.Count()); }
public void Constructor_SetsProperties() { var classifications = new List <string> { "ClassA", "ClassB" }; var dut = new GetAllDisciplinesQuery("PCS$TESTPLANT", classifications); Assert.AreEqual("PCS$TESTPLANT", dut.Plant); Assert.AreEqual(classifications, dut.Classifications); }
public async Task Handle_ReturnsAllElements_WhenNoClassificationsAreGiven() { _clientMock .Setup(x => x.QueryAndDeserializeAsync <List <MainApiDiscipline> >(_urlWithoutClassifications)) .Returns(Task.FromResult(_disciplines)); var request = new GetAllDisciplinesQuery(Plant, null); var dut = new GetAllDisciplinesQueryHandler(_clientMock.Object, _optionsMonitorMock.Object); var result = await dut.Handle(request, default); Assert.AreEqual(2, result.Data.Count()); }
public void Setup() { var options = new MainApiOptions { ApiVersion = "1", Audience = "Aud", BaseAddress = "http://example.com/" }; _optionsMonitorMock = new Mock <IOptionsMonitor <MainApiOptions> >(); _optionsMonitorMock .Setup(x => x.CurrentValue) .Returns(options); var classifications = new List <string> { "ClassA", "ClassB" }; _requestWithClassifications = new GetAllDisciplinesQuery(Plant, classifications); _urlWithClassifications = $"{options.BaseAddress}Library/Disciplines" + $"?plantId={Plant}" + string.Join("", classifications .Where(c => c != null) .Select(c => $"&classifications={c.ToUpper()}")) + $"&api-version={options.ApiVersion}"; _urlWithoutClassifications = $"{options.BaseAddress}Library/Disciplines" + $"?plantId={Plant}" + $"&api-version={options.ApiVersion}"; _disciplines = new List <MainApiDiscipline> { new MainApiDiscipline { Code = "CodeA", Description = "DescriptionA" }, new MainApiDiscipline { Code = "CodeB", Description = "DescriptionB" } }; _clientMock = new Mock <IBearerTokenApiClient>(); }