public async Task SwipeDirect(SwipeActionToScreen swipeActionToScreen)
        {
            var mosaicStore  = _mosaicStoreManager.MosaicStore;
            var swipeRelayer = _mosaicStoreManager.SwipeRelayer;

            var directionToHuman = EnumHelper.GetEnumDescription(swipeActionToScreen.Direction);
            var screenIdToHuman  = GuidHelper.Shorter(swipeActionToScreen.ScreenId);

            var message = $"[Match] Swipe Direct > ScreenId {screenIdToHuman} > To {swipeActionToScreen.ToScreenIdShort} > direction {directionToHuman}";

            await Log(message);

            var matchResult = swipeRelayer.Match(swipeActionToScreen);

            var matchMessage = string.Empty;

            if (matchResult.IsMatch)
            {
                mosaicStore.ClearAppsEmpty();

                matchMessage = $"[Mosaix] Match > {matchResult.IsMatch} > Father (Screen {matchResult.ItemFather.Screen.ConnectionId}) > Son (Screen) {matchResult.ItemSon.Screen.ConnectionId}";


                await Clients.Client(matchResult.ItemFather.Screen.ConnectionId.ToString())
                .SendAsync("match", matchResult.ItemFatherNeighborStatus);

                await Clients.Client(matchResult.ItemSon.Screen.ConnectionId.ToString())
                .SendAsync("match", matchResult.ItemSonNeighborStatus);
            }

            if (!string.IsNullOrEmpty(matchMessage))
            {
                await Log(matchMessage);
            }
        }
Exemple #2
0
        public void Should_Match_WhenActionSwipeToScreen()
        {
            _mosaicStore.Clear();

            var screenId1     = Guid.NewGuid();
            var connectionId1 = Guid.NewGuid();
            var screen1       = new Screen(screenId1, 100, 200, connectionId1.ToString());

            var mosaic1 = _mosaicStore.CreateOrUpdate(screen1);

            var screenId2     = Guid.NewGuid();
            var connectionId2 = Guid.NewGuid();
            var screen2       = new Screen(screenId2, 100, 200, connectionId2.ToString());

            var mosaic2 = _mosaicStore.CreateOrUpdate(screen2);

            var swipeActionToScreen = new SwipeActionToScreen(screenId1.ToString(),
                                                              screen2.IdShort,
                                                              DirectionEnum.Right);


            var matchResult = _swipeRelayer.Match(swipeActionToScreen);

            Assert.NotNull(matchResult);
            Assert.True(matchResult.IsMatch);
            Assert.Equal(screen1.Id.ToString(), matchResult.ItemFather.Screen.Id.ToString());
            Assert.Equal(screen2.Id.ToString(), matchResult.ItemSon.Screen.Id.ToString());
            Assert.Equal <DirectionEnum>(DirectionEnum.Right, matchResult.Direction);
        }
Exemple #3
0
        public void Should_Match_WhenActionSwipeToScreenInChain(int screenToAdd)
        {
            var mosaics    = new List <Mosaic>();
            var screens    = new List <Screen>();
            var screensNew = new List <Screen>();

            for (int i = 1; i <= screenToAdd; i++)
            {
                var screenId     = Guid.NewGuid();
                var connectionId = Guid.NewGuid();
                var screen       = new Screen(screenId, 100, 200, connectionId.ToString());
                var mosaic       = _mosaicStore.CreateOrUpdate(screen);

                mosaics.Add(mosaic);
                screens.Add(screen);
            }

            for (int i = 0; i < screenToAdd - 1; i++)
            {
                var fatherScreen = screens[i];
                var sonScreen    = screens[i + 1];


                var swipeActionToScreen = new SwipeActionToScreen(fatherScreen.Id.ToString(),
                                                                  sonScreen.IdShort,
                                                                  DirectionEnum.Right);


                var matchResult = _swipeRelayer.Match(swipeActionToScreen);

                Assert.NotNull(matchResult);
                Assert.True(matchResult.IsMatch);
                Assert.Equal(fatherScreen.Id.ToString(), matchResult.ItemFather.Screen.Id.ToString());
                Assert.Equal(sonScreen.Id.ToString(), matchResult.ItemSon.Screen.Id.ToString());
                Assert.Equal <DirectionEnum>(DirectionEnum.Right, matchResult.Direction);
            }

            Assert.Single(_mosaicStore.Apps);
        }