public void Should_Not_Retrieve_Context_From_Accessor_At_Constructor() { // Arrange // Act var _ = new TenantIdHeaderHttpTokenResolver(_mockHttpContextAccessor.Object, string.Empty); // Assert _mockHttpContextAccessor.Verify(a => a.HttpContext, Times.Never()); }
public void Should_Return_Null_If_Context_Is_Null() { // Arrange _mockHttpContextAccessor.Setup(a => a.HttpContext).Returns((HttpContext)null); var sut = new TenantIdHeaderHttpTokenResolver(_mockHttpContextAccessor.Object, string.Empty); // Act var result = sut.GetTenantToken().Result; // Assert result.Should().BeNull(); }
public void Should_Return_Null_When_The_Key_Is_Bad() { // Arrange var hKey = "bad key"; var sut = new TenantIdHeaderHttpTokenResolver(_mockHttpContextAccessor.Object, hKey); // Act var result = sut.GetTenantToken().Result; // Assert result.Should().BeNull(); }
public void Should_Return_Value_From_Header() { // Arrange var hKey = "key"; var hValue = "value"; _mockHeaders.Setup(h => h[hKey]).Returns(new StringValues(hValue)); var sut = new TenantIdHeaderHttpTokenResolver(_mockHttpContextAccessor.Object, hKey); // Act var result = sut.GetTenantToken().Result; // Assert result.Should().Be(hValue); }
public void Should_Retrieve_Headers_From_Request_From_Context_From_Accessor() { // Arrange var hKey = "key"; var hValue = "value"; _mockHeaders.Setup(h => h[hKey]).Returns(new StringValues(hValue)); var sut = new TenantIdHeaderHttpTokenResolver(_mockHttpContextAccessor.Object, hKey); // Act var _ = sut.GetTenantToken().Result; // Assert _mockHttpContextAccessor.Verify(a => a.HttpContext, Times.Once()); _mockHttpContext.Verify(c => c.Request, Times.Once()); _mockHttpRequest.Verify(r => r.Headers, Times.Once()); }