public void Constructor_SetsProperties() { var dut = new GetFunctionalRolesByCodesQuery("PCS$TESTPLANT", new List <string> { "NOTIFICATION-COMPANY-AUTHORIZED" }, "NOTIFICATION"); Assert.AreEqual("PCS$TESTPLANT", dut.Plant); Assert.AreEqual(1, dut.Codes.Count); Assert.AreEqual("NOTIFICATION-COMPANY-AUTHORIZED", dut.Codes[0]); }
public void Setup() { _personInFunctionalRole = new PersonInFunctionalRole() { AzureOid = "3BFB54C7-91E2-422E-833F-951AD07FE37F", Email = "*****@*****.**", FirstName = "FirstName", LastName = "LastName", UserName = "******" }; _persons = new List <PersonInFunctionalRole> { _personInFunctionalRole }; var options = new MainApiOptions { ApiVersion = "1", Audience = "Aud", BaseAddress = "http://example.com/" }; _optionsMonitorMock = new Mock <IOptionsMonitor <MainApiOptions> >(); _optionsMonitorMock .Setup(x => x.CurrentValue) .Returns(options); _request = new GetFunctionalRolesByCodesQuery(Plant, Codes, Classification); var functionalRoleCodes = Codes.Aggregate("", (current, code) => current + $"&functionalRoleCodes={code}"); var url = $"{options.BaseAddress}Library/FunctionalRolesByCodes" + $"?plantId={_request.Plant}" + functionalRoleCodes + $"&classification={Classification}" + $"&api-version={options.ApiVersion}"; var functionalRoles = new List <MainApiFunctionalRole> { new MainApiFunctionalRole { Code = "CodeA", Description = "DescriptionA", Email = "*****@*****.**", InformationEmail = "*****@*****.**", UsePersonalEmail = true, Persons = _persons }, }; _clientMock = new Mock <IBearerTokenApiClient>(); _clientMock .Setup(x => x.QueryAndDeserializeAsync <List <MainApiFunctionalRole> >(url)) .Returns(Task.FromResult(functionalRoles)); _dut = new GetFunctionalRolesByCodesQueryHandler(_clientMock.Object, _optionsMonitorMock.Object); }