Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "firnas"

Hi,

Can i know how to use the settingsmanager in a static method?

Thanks for the response. I will change accordingly and test.

Both the ways did not work.

Below is the unit testing code,

LoginAsDefaultTenantAdmin();

            //arrange
            var mockBusinessDomainService = new Mock<IBusinessDomainService>();
            mockBusinessDomainService.Setup(b => b.GetBusinessFromUser(It.IsAny<long>()))
                .ReturnsAsync(new Business.Business
                {
                    BusinessName = "Test Business",
                    SubscriptionStatus = Enums.SubscriptionStatus.Subscribed.ToString()
                });
            mockBusinessDomainService.Setup(b => b.UpdateBusiness(It.IsAny<string>(), It.IsAny<Business.Business>()))
                .ReturnsAsync(new Business.Business
                {
                    BusinessName = "Test Business",
                    SubscriptionStatus = Enums.SubscriptionStatus.UnSubscribed.ToString()
                });


            IBusinessAppService _businessAppService = new BusinessAppService(
                mockBusinessDomainService.Object,
                Resolve<IObjectMapper>(),
                Resolve<IUnitOfWorkManager>(),
                Resolve<SignInManager>()
                );

            //act
            Task t = _businessAppService.CancelSubscription();

Below is part of the method,

//check for user
            long userId = AbpSession.UserId.GetValueOrDefault();

            if (userId == 0)
            {
                throw new UnauthorizedAccessException();
            }

The user id is always 0. That is the problem.

AbpSession.UserId is null when running unit tests. Is there a way i can set the user id in the unit test? I am mocking my App service for testing

Solved the issue. It seemed that my wrokspace solution was corrupted somehow. taking a fresh copy to a different location solved the issue.

Thanks

I have a App service which was working fine earlier. However when i try to invoke a method in the app service now it throws a 500 internal server error. I set a debug point in the method but it is not hitting. I then set a debug point at the constructor level but still even that is not hit.

Is there a place when the error is logged so that i can trouble shoot the issue?

Thanks. I implemented a NullSendGridEmailSender and it worked.

Is there any examples of such implementation i can refer to?

When I run the unit tests i see that the Should_Register unit test in AccountAppService_Tests fails. When troubleshooting the issue as to why it is failing, i figured out that it is failing when trying to send the email avtivation link,

await _userEmailer.SendEmailActivationLinkAsync(user, emailActivationLink);

I see that the IEmailSender is assigned NullEmailSender if in debug mode in the Core module,

if (DebugHelper.IsDebug) { //Disabling email sending in debug mode Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient); }

I have implemented a interface ISendGridEmailSender which sends emails using sendgrid. While debugging i see that sending the activation link uses this service. That why the unit test is failing.

I tried to assign the NullEmailSender to the implemented ISendGridEmailSender as follows,

Configuration.ReplaceService<ISendGridEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);

This gives an error stating that there is no implicit reference conversion between the two. How can I passing the NullEmailSender to the interface i have implemened and get the unit test to pass?

Thanks aaron for ths support.

Showing 21 to 30 of 64 entries