Exemple #1
0
        public async Task TestCatalogAssignmentSync()
        {
            //arrange
            var buyerId = "buyer1";
            var useriD  = "user1";
            var currentLocationCatalogLists = new List <List <string> >()
            {
                new List <string>()
                {
                    "123", "456"
                },
                new List <string>()
                {
                    "456, 789", "910"
                }
            };
            var currentCatalogAssignments = new List <string>()
            {
                "123", "456", "789", "000"
            };

            var currentLocationPermissionAssignments = new List <string>()
            {
                "321"
            };

            _oc.UserGroups.ListUserAssignmentsAsync(buyerID: Arg.Any <string>(), userID: Arg.Any <string>(), page: Arg.Any <int>(), pageSize: Arg.Any <int>())
            .ReturnsForAnyArgs(Task.FromResult(GetUserGroupAssignments()));
            _oc.UserGroups.ListAsync <HSLocationUserGroup>(buyerID: Arg.Any <string>(), filters: Arg.Any <string>())
            .ReturnsForAnyArgs(GetUserGroups(currentLocationCatalogLists, currentCatalogAssignments, currentLocationPermissionAssignments));


            //act
            await _sut.SyncUserCatalogAssignments(buyerId, useriD);

            //assert
            await _oc.UserGroups.Received().SaveUserAssignmentAsync(buyerId, Arg.Is <UserGroupAssignment>(assignment => assignment.UserGroupID == "910"));

            await _oc.UserGroups.Received().DeleteUserAssignmentAsync(buyerId, "000", useriD);

            await _oc.UserGroups.DidNotReceive().DeleteUserAssignmentAsync(buyerId, "321", useriD);
        }
 public async Task SyncOnRemoveFromLocation(string buyerID, string userID)
 {
     await _command.SyncUserCatalogAssignments(buyerID, userID);
 }