I have a controller, where I'm calling a userId:
var userId = User.Identity.GetUserId();
This makes my unit test fail, since User is null.
I've tried to set a user in the test method using this method, but User is still null in the controller when the test runs.
var context = new Mock<HttpContextBase>();
var mockIdentity = new Mock<IIdentity>();
context.SetupGet(x => x.User.Identity).Returns(mockIdentity.Object);
mockIdentity.Setup(u => u.Name).Returns("test_userName");
Any hints as to what I'm doing wrong?
The HttpContextBase.User is of type IPrincipal and you have not mocked it. That's why it is returning null when you access it in tests. You can mock it as follows
var controllerContext = new Mock<ControllerContext>();
var principal = new Moq.Mock<IPrincipal>();
principal.Setup(p => p.IsInRole("Administrator")).Returns(true);
principal.SetupGet(x => x.Identity.Name).Returns(userName);
controllerContext.SetupGet(x => x.HttpContext.User).Returns(principal.Object);
controller.ControllerContext = controllerContext.Object;
Here is the reference of this code
Okay, so according to this post, you can do it like this:
public class MyController: Controller
{
public Func<string> GetUserId; //For testing
public MyController()
{
GetUserId = () => User.Identity.GetUserId();
}
//controller actions
}
And then instead of caling User.Identity.GetUserId() when you want the user, you just call GetUserId() and mock out the user id in your test:
controller = new MyController()
{
GetUserId = () => "IdOfYourChoosing"
};
You are mocking HttpContextBase but are not passing it to your controller.
Try this pattern:
Class:
public MyClass
{
private readonly HttpContextBase _contextBase;
public MyClass(HttpContextBase contextBase)
{
this._contextBase = contextBase;
}
public void Process()
{
var userId = _contextBase.User.Identity;
}
}
Test:
[Test]
public void MyClass_Test_SO()
{
// arrange
var context = new Mock<HttpContextBase>();
var mockIdentity = new Mock<IIdentity>();
context.SetupGet(x => x.User.Identity).Returns(mockIdentity.Object);
mockIdentity.Setup(u => u.Name).Returns("test_userName");
var sut = new MyClass(context.Object);
// act
sut.Process();
// assert
// ... whatever
}
Related
ignore everything
ignore everything
public class BaseController : ApiController
{
ignore everything
public UserIdentity => User.Identity as ;
public int UserId => Int32.Parse(Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value);
}
This is my class
Create a fake principal and give that to the controller before exercising the unit test
[TestMethod()]
public void BaseController_When_Authenticated_Should_Return_UserId() {
//Arrange
//Create test user
var expected = 12345;
var identity = new LtfClaimsIdentity("Ltf"); // Or how ever it is you initialize your identity
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, expected.ToString()));
var user = new ClaimsPrincipal(identity);
// Set the User on the controller directly
var controller = new BaseController () {
User = user
};
//Act
var actual = controller.UserId;
//Assert
Assert.AreEqual(expected, actual);
}
In our MVC4 application with Entity Framework 4.0 based on the Music Store Tutorial we are using Moq to mock the DbContext and unit test are logic. One of our methods proves difficult to test though since it makes use of HttpContext or HttpContextBase. One example method looks like this:
public static ShoppingCart GetCart(HttpContextBase context)
{
var cart = new ShoppingCart();
cart.ShoppingCartId = cart.GetCartId(context);
return cart;
}
The only property collected from HttpContextBase is the [CartSessionKey] as can be seen here:
public string GetCartId(HttpContextBase context)
{
if (context.Session[CartSessionKey] == null)
{
if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
{
context.Session[CartSessionKey] =
context.User.Identity.Name;
}
else
{
// Generate a new random GUID using System.Guid class
Guid tempCartId = Guid.NewGuid();
// Send tempCartId back to client as a cookie
context.Session[CartSessionKey] = tempCartId.ToString();
}
}
return context.Session[CartSessionKey].ToString();
}
We have heard horror stories that HttpContext is a very complex class and that if you print it you have enough paper to circle the earth eight times.
Nevertheless we want to mock it. The question is how. The properties that we want to mock are the [CartSessionKey], and the property that come from the context as contest.User.Identity.Name.
We suspect we need to use something like this:
var mockData = new Mock<FakeContext>();
mockData.Setup(m => m.Orders).Returns(memoryOrderItems);
mockData.Setup(m => m.Carts).Returns(memoryCartItems);
Mock<HttpContextBase> mockHttpContext = new Mock<HttpContextBase>();
Mock<HttpRequestBase> mockHttpRequest = new Mock<HttpRequestBase>();
mockHttpRequest.Setup(x => x.CartSessionKey).Returns(1);
mockHttpContext.Setup(x => x.Request).Returns(mockHttpRequest.Object);
but we cannot find how to specifically implement this so we do not get any errors on methods that use context.Session[CartSessionKey] or context.User.Identity.Name.
We hope someone can help us out.
/edit
When we do this:
var memoryUserItems = new FakeDbSet<User>()
{
new User { Email = "test#test.de",
FullName = "Test Person",
isAvailable = true,
Name = "WHat"
},
new User { Email = "test2#test.de",
FullName = "Test Person 2",
isAvailable = true,
Name = "WHat 2"
}
};
(...) Other memory...Items
And then this:
// Create mock units of work
var mockData = new Mock<FakeContext>();
mockData.Setup(m => m.Orders).Returns(memoryOrderItems);
mockData.Setup(m => m.Carts).Returns(memoryCartItems);
mockData.Setup(m => m.Users).Returns(memoryUserItems);
var principalMock = new Mock<IPrincipal>();
var identityMock = new Mock<IIdentity>();
var userMock =
identityMock.Setup(x => x.Name).Returns("Test!");
identityMock.Setup(x => x.IsAuthenticated).Returns(true); // optional ;)
mockData.Setup(x => x.Identity).Returns(identityMock.Object);
var httpReqBase = new Mock<HttpRequestBase>(); // this is useful if you want to test Ajax request checks or cookies in the controller.
var httpContextBase = new Mock<HttpContextBase>();
httpContextBase.Setup(x => x.User).Returns(principalMock.Object);
httpContextBase.Setup(x => x.Session[It.IsAny<string>()]).Returns(1); //Here is the session indexer. You can swap 'any' string for specific string.
httpContextBase.Setup(x => x.Request).Returns(httpReqBase.Object);
We get the error that:
Error 3 'project.Models.FakeContext' does
not contain a definition for 'Identity' and no extension method
'Identity' accepting a first argument of type
'project.Models.FakeContext' could be found
(are you missing a using directive or an assembly
reference?)
/ edit2
To make it more clear. The actual method I am testing is the following:
public ActionResult Complete(int id)
{
// Make sure that user is currentuser and otherwise bring user to our Thief page
if (id != db.GetCurrentUserId())
{
return View("Thief");
}
var cart = ShoppingCart.GetCart(this.HttpContext);
var currentDate = DateTime.Today;
var viewModel = new ShoppingCartViewModel
{
CartItems = cart.GetCartItems(),
CartTotal = cart.GetTotal(),
ProductItems = db.Products.ToList()
};
if (viewModel.CartItems.Count() == 0)
{
return View("Empty");
}
// Try to write cart to order table
try
{
foreach (var item in viewModel.CartItems)
{
ProcessOrder(item, id, currentDate);
}
// after this we empty the shopping cart
cart.EmptyCart();
return View();
}
catch
{
// Invalid - display error page
return View("Error");
}
}
As can be seen the var cart = ShoppingCart.GetCart(this.HttpContext); uses this.HttpContext. In the test I just do controller.Complete(1). I cannot pass a new HttpContext to the controller I guess?
/ edit 3
While using the code below with the mocks I get the following message:
Test Name: TestCheckoutCompleteShouldWithEmptyCart
Test FullName: Controllers.CheckoutControllerTest.TestCheckoutCompleteShouldWithEmptyCart
Test Source: Controllers\CheckoutControllerTest.cs : line 141
Test Outcome: Failed
Test Duration: 0:00:00.0158591
Result Message:
Test method Controllers.CheckoutControllerTest.TestCheckoutCompleteShouldWithEmptyCart threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Result StackTrace:
at Models\ShoppingCart.cs:line 170
at \Models\ShoppingCart.cs:line 20
at \Controllers\CheckoutController.cs:line 48
at Controllers\CheckoutControllerTest.cs:line 143
OK, here it goes. The following works in MVC5 with AD, I'm not sure if it's fully backwards compatible, you'll have to check.
var principalMock = new Mock<IPrincipal>();
var identityMock = new Mock<IIdentity>();
identityMock.Setup(x => x.Name).Returns("Test!");
identityMock.Setup(x => x.IsAuthenticated).Returns(true); // optional ;)
userMock.Setup(x => x.Identity).Returns(identityMock.Object);
var httpReqBase = new Mock<HttpRequestBase>(); // this is useful if you want to test Ajax request checks or cookies in the controller.
var httpContextBase = new Mock<HttpContextBase>();
httpContextBase.Setup(x => x.User).Returns(principalMock.Object);
httpContextBase.Setup(x => x.Session[It.IsAny<string>()]).Returns(1); //Here is the session indexer. You can swap 'any' string for specific string.
httpContextBase.Setup(x => x.Request).Returns(httpReqBase.Object);
This would help you to write a proper Unit Test using Moq.
[TestClass]
public class SutTest
{
[TestMethod]
public void GetCartId_WhenUserNameIsNotNull_SessionContainsUserName()
{
var httpContextStub = new Mock<HttpContextBase>();
var httpSessionStub = new Mock<ISessionSettings>();
httpSessionStub.Setup(x => x.Get<string>(It.IsAny<string>())).Returns(() => null);
httpSessionStub.SetupSequence(x => x.Get<string>(It.IsAny<string>()))
.Returns(null)
.Returns("FakeName");
var httpUserStub = new Mock<IPrincipal>();
var httpIdenttyStub = new Mock<IIdentity>();
httpUserStub.SetupGet(x => x.Identity).Returns(httpIdenttyStub.Object);
httpIdenttyStub.SetupGet(x => x.Name).Returns("FakeName");
httpContextStub.Setup(x => x.User).Returns(httpUserStub.Object);
var sut = new Sut(httpSessionStub.Object);
var result = sut.GetCartId(httpContextStub.Object);
Assert.AreEqual("FakeName",result );
}
}
Check the SetupSequence method which gives you find Control over different values being return on he same stubbed call.
Also important to decouple your session from HttpContext as you can always run into issues.
public class SessionSettings : ISessionSettings
{
private readonly HttpSessionStateBase _session;
public SessionSettings(HttpSessionStateBase session)
{
_session = session;
}
public T Get<T>(string key)
{
return (T)_session[key];
}
public void Set<T>(string key, T value)
{
_session[key] = value;
}
}
public interface ISessionSettings
{
T Get<T>(string key);
void Set<T>(string key, T value);
}
public class Sut
{
private ISessionSettings _sessionSettings;
public Sut(ISessionSettings sessionSettings)
{
_sessionSettings = sessionSettings;
}
public string GetCartId(HttpContextBase context)
{
if (_sessionSettings.Get<string>(CartSessionKey) == null)
{
if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
{
_sessionSettings.Set<string>(CartSessionKey, context.User.Identity.Name);
}
else
{
// Generate a new random GUID using System.Guid class
Guid tempCartId = Guid.NewGuid();
// Send tempCartId back to client as a cookie
_sessionSettings.Set<string>(CartSessionKey, tempCartId.ToString());
}
}
return _sessionSettings.Get<string>(CartSessionKey);
}
private string CartSessionKey = "key";
}
This way the code is more readable and easier to understand.
I'm using Moq for the first time, and I'm struggling with getting the tests to run properly.
I'm trying to moq the Save() method of my service layer.
public void Save(UserViewModel viewModel)
{
// todo: this still doesn't address updating a password. The UserViewModel doesn't contain any Password data.
if (viewModel.Id != Guid.Empty)
{
// The UserId is not empty, we're either updating an existing user
// or we're inserting a new user via sync
var user = _userRepository.GetById(viewModel.Id);
if (user != null)
{
// Looks like we're updating a user because they're already in the database.
_userRepository.Update(_userViewModelToModelMapper.BuildFrom(viewModel));
return;
}
}
// The user is being created, either via a Sync (Guid Exists), or via an Insert (Guid doesn't Exist)
_userRepository.Create(_userViewModelToModelMapper.BuildFrom(viewModel));
}
I've got Three tests, of which, I'm not sure any of them are right. The first two are passing, but the third one fails with
Moq.MockVerificationException : The following setups were not matched:
IUserRepository r => r.Update(It.Is(um => um.Equals()))
Here are the tests.
// PASSES but could be suspect
[Test]
public void ShouldSaveANewUserFromExistingId()
{
// emulating a "sync"
// Setup
var userId = new Guid("81C7FE19-2DB5-4083-BD6A-5433687561F7");
var userModel = new UserModel();
var userViewModel = new UserViewModel {Id = userId};
var userRepository = new Mock<IUserRepository>();
var viewModelToModelMapper = new Mock<IAutoMapper<UserViewModel, UserModel>>();
var modelToViewModelMapper = new Mock<IAutoMapper<UserModel, UserViewModel>>();
// Setup the Mock UserRepository
userRepository.Setup(r => r.Create(It.Is<UserModel>(um => um.Equals(userModel))));
viewModelToModelMapper.Setup(vmm => vmm.BuildFrom(It.Is<UserViewModel>(u => u.Equals(userViewModel))))
.Returns(userModel);
var userService = new UserService(userRepository.Object, viewModelToModelMapper.Object, modelToViewModelMapper.Object);
// Execute
userService.Save(userViewModel);
// Assert
userRepository.VerifyAll();
viewModelToModelMapper.VerifyAll();
}
// PASSES but could be suspect.
[Test]
public void ShouldSaveANewUser()
{
// emulating a standard create
// Setup
var userId = Guid.Empty;
var userModel = new UserModel();
var userViewModel = new UserViewModel { Id = userId };
var userRepository = new Mock<IUserRepository>();
var viewModelToModelMapper = new Mock<IAutoMapper<UserViewModel, UserModel>>();
var modelToViewModelMapper = new Mock<IAutoMapper<UserModel, UserViewModel>>();
// Setup the Mock UserRepository
userRepository.Setup(r => r.Create(It.Is<UserModel>(um => um.Equals(userModel))));
viewModelToModelMapper.Setup(vmm => vmm.BuildFrom(It.Is<UserViewModel>(u => u.Equals(userViewModel))))
.Returns(userModel);
var userService = new UserService(userRepository.Object, viewModelToModelMapper.Object, modelToViewModelMapper.Object);
// Execute
userService.Save(userViewModel);
// Assert
userRepository.VerifyAll();
viewModelToModelMapper.VerifyAll();
}
// FAILS MISERABLY
[Test]
public void ShouldSaveAnExistingUser()
{
// emulating an "Update"
// Setup
var userId = new Guid("0A88AEC2-9F8D-44DE-BD01-3EB9A23C78E3");
var userModel = new UserModel { Id = userId };
var userViewModel = new UserViewModel { Id = userId };
var userRepository = new Mock<IUserRepository>();
var viewModelToModelMapper = new Mock<IAutoMapper<UserViewModel, UserModel>>();
var modelToViewModelMapper = new Mock<IAutoMapper<UserModel, UserViewModel>>();
// Setup the Mock UserRepository
userRepository.Setup(r => r.Update(It.Is<UserModel>(um => um.Equals(userModel))));
viewModelToModelMapper.Setup(vmm => vmm.BuildFrom(It.Is<UserViewModel>(u => u.Equals(userViewModel))))
.Returns(userModel);
var userService = new UserService(userRepository.Object, viewModelToModelMapper.Object, modelToViewModelMapper.Object);
// Execute
userService.Save(userViewModel);
// Assert
userRepository.VerifyAll();
viewModelToModelMapper.VerifyAll();
}
Where am I going wrong with my Moqing?
Seems like in the last case you would need:
userRepository.Setup(r => r.GetById(userId)).Returns(userModel);
Before the userService.Save call. Without it userRepository.GetById will always be null and the update branch will never be taken.
It's been a while since I did any MVC work, so I'm hopefully missing something. I'm trying to write a test and controller action to simply Edit a DTO named "Business".
Controller Action:
[HttpPost]
public ActionResult Edit(string id, Business business)
{
try
{
var model = _businessRepository.Get(id);
if (model != null)
{
UpdateModel(model);
if (ModelState.IsValid)
{
_businessRepository.Save(model);
}
else
{
return View(business);
}
}
return RedirectToAction("Index");
}
catch
{
return View();
}
}
Test:
[TestMethod]
public void Edit_Post_Action_Updates_Model_And_Redirects()
{
// Arrange
var mockBusinessRepository = new Mock<IBusinessRepository>();
var model = new Business { Id = "1", Name = "Test" };
var expected = new Business { Id = "1", Name = "Not Test" };
// Set up result for business repository
mockBusinessRepository.Setup(m => m.Get(model.Id)).Returns(model);
mockBusinessRepository.Setup(m => m.Save(expected)).Returns(expected);
var businessController = new BusinessController(mockBusinessRepository.Object);
// Act
var result = businessController.Edit(model.Id, expected) as RedirectToRouteResult;
// Assert
Assert.IsNotNull(result);
Assert.AreEqual(result.RouteValues["action"], "Index");
mockBusinessRepository.VerifyAll();
}
The line that it is giving an exception on, is the UpdateModel() in the controller. The exception details are:
"Value cannot be null. Parameter name: controllerContext"
I have some code on Gist that I typically use to set up that ControllerContext. The code is a modified version that was originally taken from Hanselman's blog.
https://gist.github.com/1578697 (MvcMockHelpers.cs)
Setup the Controller context
The following is code snippet from a project which I work on, so maybe it's to much for you
public class TestBase
{
internal Mock<HttpContextBase> Context;
internal Mock<HttpRequestBase> Request;
internal Mock<HttpResponseBase> Response;
internal Mock<HttpSessionStateBase> Session;
internal Mock<HttpServerUtilityBase> Server;
internal GenericPrincipal User;
public void SetContext(Controller controller)
{
Context = new Mock<HttpContextBase>();
Request = new Mock<HttpRequestBase>();
Response = new Mock<HttpResponseBase>();
Session = new Mock<HttpSessionStateBase>();
Server = new Mock<HttpServerUtilityBase>();
User = new GenericPrincipal(new GenericIdentity("test"), new string[0]);
Context.Setup(ctx => ctx.Request).Returns(Request.Object);
Context.Setup(ctx => ctx.Response).Returns(Response.Object);
Context.Setup(ctx => ctx.Session).Returns(Session.Object);
Context.Setup(ctx => ctx.Server).Returns(Server.Object);
Context.Setup(ctx => ctx.User).Returns(User);
Request.Setup(r => r.Cookies).Returns(new HttpCookieCollection());
Request.Setup(r => r.Form).Returns(new NameValueCollection());
Request.Setup(q => q.QueryString).Returns(new NameValueCollection());
Response.Setup(r => r.Cookies).Returns(new HttpCookieCollection());
var rctx = new RequestContext(Context.Object, new RouteData());
controller.ControllerContext = new ControllerContext(rctx, controller);
}
}
Then in your tests you can arrange:
//Arrange
SetContext(_controller);
Context.Setup(ctx => ctx.Request).Returns(Request.Object);
If you want to test your method with ModelState errors, add:
_controller.ModelState.AddModelError("Name", "ErrorMessage");
You need to mock the ControllerContext for your BusinessController.
See this question or this one.
I've managed to get what I wanted working by using Automapper instead of the UpdateModel.
I added in my automapper initialization (IPersistable is an interface for all my DTOs):
Mapper.CreateMap<IPersistable, IPersistable>().ForMember(dto => dto.Id, opt => opt.Ignore());
I then changed my controller action to:
[HttpPost]
public ActionResult Edit(string id, Business business)
{
try
{
var model = _businessRepository.Get(id);
if (model != null)
{
Mapper.Map(business, model);
if (ModelState.IsValid)
{
_businessRepository.Save(model);
}
else
{
return View(business);
}
}
return RedirectToAction("Index");
}
catch
{
return View();
}
}
And changed my test to:
[TestMethod]
public void Edit_Post_Action_Updates_Model_And_Redirects()
{
// Arrange
var mockBusinessRepository = new Mock<IBusinessRepository>();
var fromDB = new Business { Id = "1", Name = "Test" };
var expected = new Business { Id = "1", Name = "Not Test" };
// Set up result for business repository
mockBusinessRepository.Setup(m => m.Get(fromDB.Id)).Returns(fromDB);
mockBusinessRepository.Setup(m => m.Save(It.IsAny<Business>())).Returns(expected);
var businessController = new BusinessController(mockBusinessRepository.Object) {ControllerContext = new ControllerContext()};
//Act
var result = businessController.Edit(fromDB.Id, expected) as RedirectToRouteResult;
// Assert
Assert.IsNotNull(result);
Assert.AreEqual(result.RouteValues["action"], "Index");
mockBusinessRepository.VerifyAll();
}
I had the same problem and used the stack trace to pin this down to the ValueProvider. Building on Andrew's answer above for mocking some of the underlying objects used by a controller, I managed to solve the null value exception by also mocking the ValueProvider like this:
var controller = new MyController();
// ... Other code to mock objects used by controller ...
var mockValueProvider = new Mock<IValueProvider>();
controller.ValueProvider = mockValueProvider.Object;
// ... rest of unit test code which relies on UpdateModel(...)
I have a couple of ActionMethods that queries the Controller.User for its role like this
bool isAdmin = User.IsInRole("admin");
acting conveniently on that condition.
I'm starting to make tests for these methods with code like this
[TestMethod]
public void HomeController_Index_Should_Return_Non_Null_ViewPage()
{
HomeController controller = new HomePostController();
ActionResult index = controller.Index();
Assert.IsNotNull(index);
}
and that Test Fails because Controller.User is not set.
Any idea?
You need to Mock the ControllerContext, HttpContextBase and finally IPrincipal to mock the user property on Controller. Using Moq (v2) something along the following lines should work.
[TestMethod]
public void HomeControllerReturnsIndexViewWhenUserIsAdmin() {
var homeController = new HomeController();
var userMock = new Mock<IPrincipal>();
userMock.Expect(p => p.IsInRole("admin")).Returns(true);
var contextMock = new Mock<HttpContextBase>();
contextMock.ExpectGet(ctx => ctx.User)
.Returns(userMock.Object);
var controllerContextMock = new Mock<ControllerContext>();
controllerContextMock.ExpectGet(con => con.HttpContext)
.Returns(contextMock.Object);
homeController.ControllerContext = controllerContextMock.Object;
var result = homeController.Index();
userMock.Verify(p => p.IsInRole("admin"));
Assert.AreEqual(((ViewResult)result).ViewName, "Index");
}
Testing the behaviour when the user isn't an admin is as simple as changing the expectation set on the userMock object to return false.
Using Moq version 3.1 (and NUnit):
[Test]
public void HomeController_Index_Should_Return_Non_Null_ViewPage()
{
// Assign:
var homeController = new HomeController();
Mock<ControllerContext> controllerContextMock = new Mock<ControllerContext>();
controllerContextMock.Setup(
x => x.HttpContext.User.IsInRole(It.Is<string>(s => s.Equals("admin")))
).Returns(true);
homeController.ControllerContext = controllerContextMock.Object;
// Act:
ActionResult index = homeController.Index();
// Assert:
Assert.IsNotNull(index);
// Place other asserts here...
controllerContextMock.Verify(
x => x.HttpContext.User.IsInRole(It.Is<string>(s => s.Equals("admin"))),
Times.Exactly(1),
"Must check if user is in role 'admin'");
}
Notice that there is no need to create mock for HttpContext, Moq supports nesting of properties when setting up the test.
When using AspNetCore I could not mock the ControllerContext since I got an exception.
Unsupported expression: m => m.HttpContext
Non-overridable members (here: ActionContext.get_HttpContext) may not be used in setup / verification expressions.
Instead I had to mock the HttpContext and create a ControllerContext and pass the HttpContext object along.
I did find that mocking claims or response/request objects works as well when using this method.
[Test]
public void TestSomeStuff() {
var name = "some name";
var httpContext = new Mock<HttpContext>();
httpContext.Setup(m => m.User.IsInRole("RoleName")).Returns(true);
httpContext.Setup(m => m.User.FindFirst(ClaimTypes.Name)).Returns(name);
var context = new ControllerContext(new ActionContext(httpContext.Object, new RouteData(), new ControllerActionDescriptor()));
var controller = new MyController()
{
ControllerContext = context
};
var result = controller.Index();
Assert.That(result, Is.Not.Null);
}