Hi everyone,
I’m looking at creating a unit test which checks that a Member exists in the backoffice - this is the first step of my tests because then I test to see if a password reset email is sent but intially I’m focussing on testing that the user either exists or not.
I was reading the documentation and I found the U8 docs -
and there is info in there about testing “GetCurrentMember” but there is nothing in the new docs and I’m not even sure if GetCurrentMember is actually what I’m trying to test.
My current test looks like this - it’s not complete and that’s where I need some help. I know I need to Mock the Membership service but I’m not sure how or what that would look like.
Any help would be appreciated on this as I would really like to get some tests written for this so I don’t need to keep on using Postman ![]()
[TestFixture(Category = "Manage Account API Testing")]
public class ManageAccountAPITests
{
private ManageAccountController controller;
[SetUp]
public void SetUp()
{
this.controller = new ManageAccountController(Mock.Of<MemberService>(),
Mock.Of<ICombinedLogger<ManageAccountController>>(),
Mock.Of<MyHttpClientService>(),
Mock.Of<IOptions<MyOptions>>(),
Mock.Of<PasswordService>(),
Mock.Of<IPublishedContentQuery>(),Mock.Of<IMyDataService>());
}
[Test]
public void CreateAnAccountInUmbraco()
{
var username = "[email protected]";
var accountCode = "ABC";
var test = this.controller.CreateAccount(username, accountCode);
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/110971-testing-membership-creation-with-unit-test