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.
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 :D
[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 might help a bit further - the ApiController I'm trying to test does the following :
The incoming request to the endpoint is sent an email address, the controller then uses the membershipService to check that the user doesn't already exist. If no member exists then it creates one.
Maybe what I'm needing to do is someone just test a small section of the controller, not the entire method. Which then makes me think, maybe I can simplify the controller a bit more. Just now the single method is making calls out to 3rd Party API to check details of a customer and also checking umbraco backoffice.
Sorry, just thinking out loud in the hope this helps somehow :)
Testing Membership Creation with unit test
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 - https://our.umbraco.com/documentation/Implementation/Unit-Testing/
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.
https://docs.umbraco.com/umbraco-cms/implementation/unit-testing/
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 :D
This might help a bit further - the ApiController I'm trying to test does the following :
The incoming request to the endpoint is sent an email address, the controller then uses the membershipService to check that the user doesn't already exist. If no member exists then it creates one.
Maybe what I'm needing to do is someone just test a small section of the controller, not the entire method. Which then makes me think, maybe I can simplify the controller a bit more. Just now the single method is making calls out to 3rd Party API to check details of a customer and also checking umbraco backoffice.
Sorry, just thinking out loud in the hope this helps somehow :)
is working on a reply...