Base solution for your next web application

Activities of "klir"

If I use

Configuration.Settings.Providers.Add<TimingSettingProvider>(); 

then I can't change the default timezone in appsetting.config it's always UTC no matter if I add the setting there. My question is how TimingSettingProvider can be updated via Environmental config settings or appsettings.

Hi all,

I've added in our core module the following settings in order to support UTC time and multitimezone

//Adding setting providers
Configuration.Settings.Providers.Add<AppSettingProvider>();
Configuration.Settings.Providers.Add<TimingSettingProvider>();
Clock.Provider = ClockProviders.Utc;

And then in our appsettings the default TimeZone

"Abp": {
  "Timing": {
    "TimeZone": "GMT Standard Time"
  }
},

However when I run the project it always displays UTC as the default timezone. As a workaround I've removed TimingSettingProvider and added it manuallly in my shared settings the following that will read that property from appsettings. Did I missed something here?

new SettingDefinition(TimingSettingNames.TimeZone, 
                                        GetFromSettings("Abp:Timing:Timezone", "UTC"), null, //TODO: Can we use here localization?
                                        scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, 
                                        clientVisibilityProvider: new VisibleSettingClientVisibilityProvider())

Regards

That's great.. But I prefer not to having to wait 5 seconds or 100ms.. I think it's just ok for now if I intercept that call. That should be sufficient to pass the test.  Thanks

//Mock Background Job an intercept queue
NotificationDistributionJobArgs calledNotification = null;
var fakeBackgroundJobManager = Substitute.For<IBackgroundJobManager>();
fakeBackgroundJobManager.EnqueueAsync<NotificationDistributionJob, NotificationDistributionJobArgs>(
    Arg.Any<NotificationDistributionJobArgs>(),
    Arg.Any<BackgroundJobPriority>()).Returns(callInfo =>
    {
        calledNotification = callInfo.Arg<NotificationDistributionJobArgs>();
        return Task.CompletedTask;
    });
LocalIocManager.IocContainer.Register(Component.For<IBackgroundJobManager>().Instance(fakeBackgroundJobManager).IsDefault());

...

//Asserts
    calledNotification
        .ShouldNotBeNull(); //

Hi,

I'm adding some tests for a global notification process. Basically I've registered an EntityCreatedEventData in the evenbus and every time a record is created a notification is published. All works ok while debugging the app. But now I want to lock this behaviour by adding some unit test that replicate this logic. However I couldn't figure out how to make this work. In the unit test below, a new notification is publised, current users is subscribed, Created Event is raised, but notificationSubscriptionManager returns always 0. Can you help me with this one?

public NotificationAppService_Tests()
{
    _notificationAppService = Resolve<INotificationAppService>();
    _userNotificationManager = Resolve<IUserNotificationManager>();
    _notificationSubscriptionManager = Resolve<INotificationSubscriptionManager>();
    _taskRepository = Resolve<IRepository<TaskEntity, long>>();
}


...


[Fact]
public async Task User_Receives_NewTaskCreated_Notification()
{
    //Subscribe current user to NewTaskCreated 
    var user = await GetCurrentUserAsync();
    await _notificationSubscriptionManager.SubscribeAsync(user.ToUserIdentifier(), AppNotificationNames.NewTaskCreated);

    //Create a new task:
    long taskId = 0;
    Action action = () =>
    {
        using (var uow = Resolve<IUnitOfWorkManager>().Begin())
        {
            taskId = _taskRepository.InsertAndGetId(new TaskEntity
            {
                Name = "New task for subscribers!!",
                CreatorUserId = AbpSession.UserId,
                LastModifierUserId = AbpSession.UserId,
                TenantId = AbpSession.TenantId,
                Code = "01",
                Description = "New task for subscribers!!",
                OwnerUserId = AbpSession.UserId,
                PermitId = 1, //Should be present in
            });


            var newTaskCreated = _taskRepository.FirstOrDefault(taskId);
            newTaskCreated.ShouldNotBeNull();

            //// Notify subscribers <== this happen in the EntityCreatedEventData once uow.Complerted()
            //// await _appNotifier.NewTaskCreatedAsync(newTaskCreated);

            uow.Complete();

        }
    };
    action
        .ShouldNotThrow();

    var userSubscriptions = _notificationSubscriptionManager
        .GetSubscribedNotifications(user.ToUserIdentifier());
    userSubscriptions
        .Count
        .ShouldBeGreaterThan(0);

    //User should receive notification
    var notifications = _userNotificationManager.GetUserNotifications(
        user.ToUserIdentifier()
    );

    //Asserts
    notifications
        .Count
        .ShouldBeGreaterThan(0); // <== **FAILS HERE retrieves 0 notifications!!!**


    var item = notifications.First();
    item.Notification
        .NotificationName
        .ShouldBe(AppNotificationNames.NewTaskCreated);

}

Definetly this recudes render time.. but is not good for debugging. I've added 2 scripts in my packages so I can run with and without sourceMap

"start-nosourcemap": "ng serve --sourceMap=false ...."

Ou sorry.. I didn't realize that in EFCore transactions are not supported for SQLite in-memory store. I'll try to see which are the limitations we have in this meaning.

https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/sqlite

Thanks

Thanks Ryan,

But that is how I have it. I just copied this unit test from aspnetboilerplate repository. The same code works here as expected. But not in my aspnetzero project.

Tests_For_EntityChangeEvents.cs

see below updated test for another repository:

[Fact]
        public void Should_Rollback_UOW_In_Updating_Event()
        {
            //Arrange
            var updatingTriggerCount = 0;
            var updatedTriggerCount = 0;

            Resolve<IEventBus>().Register<EntityUpdatingEventData<Facility>>(
                eventData =>
                {
                    eventData.Entity.Name.Should().Be("Facility 2");
                    updatingTriggerCount++;

                    throw new ApplicationException("A sample exception to rollback the UOW.");
                });

            Resolve<IEventBus>().Register<EntityUpdatedEventData<Facility>>(
                eventData =>
                {
                    //Should not come here, since UOW is failed
                    updatedTriggerCount++;
                });

            //Act
            Action action = () =>
            {
                using (var uow = Resolve<IUnitOfWorkManager>().Begin())
                {
                    var facility = _facilityRepository.Single(p => p.Name == "Facility");
                    facility.Name = "Facility 2";
                    _facilityRepository.Update(facility);

                    uow.Complete();
                }

                Assert.True(false, "Should not come here since ApplicationException is thrown!");
            };
            action
                .Should()
                .Throw<ApplicationException>();

            //Assert
            updatingTriggerCount.Should().Be(1);
            updatedTriggerCount.Should().Be(0);

            _facilityRepository
                .FirstOrDefault(p => p.Name == "Facility")
                .Should()
                    .NotBeNull("should not be changed since we throw exception to rollback the transaction");
        }

Hi, According to documentation "ing" events are atomic, but when running the following test entity is actually updated. Issue 751

[Fact]
        public void Should_Rollback_UOW_In_Updating_Event()
        {
            //Arrange
            var updatingTriggerCount = 0;
            var updatedTriggerCount = 0;
            Resolve<IEventBus>().Register<EntityUpdatingEventData<Permit>>(
               eventData =>
               {
                   eventData.Entity.Name.Should().Be("Permit 2");
                   updatingTriggerCount++;
                   throw new ApplicationException("A sample exception to rollback the UOW.");
               });
            Resolve<IEventBus>().Register<EntityUpdatedEventData<Permit>>(
               eventData =>
               {
                   //Should not come here, since UOW is failed
                   updatedTriggerCount++;
               });

            //Act
            try
            {
                using (var uow = Resolve<IUnitOfWorkManager>().Begin())
                {
                    var person = _permitRepository.Single(p => p.Name == "Permit");
                    person.Name = "Permit 2";
                    _permitRepository.Update(person);
                    uow.Complete();
                }
                Assert.True(false, "Should not come here since ApplicationException is thrown!");
            }
            catch (ApplicationException)
            {
                //hiding exception
            }
            //Assert
            updatingTriggerCount.Should().Be(1);
            updatedTriggerCount.Should().Be(0);
            _permitRepository
               .FirstOrDefault(p => p.Name == "Permit")
               .Should()
                .NotBeNull(); //should not be changed since we throw exception to rollback the transaction
        }

It fails in the last validation where the Permit name should be the original name. Any ideas why this happen?

Regards

Thanks. I've updated flaticon folder with the new version and now it's all ok.

Question

Hi, according to the documentation flaticons used are https://keenthemes.com/metronic/preview/?page=components/icons/flaticon&demo=default However the version I can download from my account it contains a different sets of icons, and seems to be just demo ones, a limited version of them.

Am I doing something wrong? Where can I get the right version of flaticons?

Regards

Showing 11 to 20 of 22 entries