コード例 #1
0
        public async Task CreateMoveCollectionAsync()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                this.TestHelper.Initialize(context);
                var client = this.TestHelper.ResourceMoverServiceClient;

                var moveCollectionProperties = new MoveCollectionProperties()
                {
                    SourceRegion = SourceRegion,
                    TargetRegion = TargetRegion
                };

                var identity = new Identity()
                {
                    Type = SystemAssignedIdentityType
                };

                var moveCollectionInput = new MoveCollection()
                {
                    Location   = MoveCollectionRegion,
                    Properties = moveCollectionProperties,
                    Identity   = identity
                };

                var moveCollection =
                    (await client.MoveCollections.CreateWithHttpMessagesAsync(
                         MoveCollectionResourceGroup,
                         MoveCollectionName,
                         moveCollectionInput)).Body;
                Assert.True(
                    moveCollection.Name == MoveCollectionName,
                    "Resource name can not be different.");
            }
        }
コード例 #2
0
        public static MoveCollection CalcMoves(FTLPair pair, Cube cube)
        {
            MoveCollection moves = new MoveCollection();

            FTLMoveCalculator.cube = (Cube)cube.Clone();

            FTLMoveCalculator.cube.OnMoveDone += Cube_OnMoveDone;

            pairs = from corner in FTLMoveCalculator.cube.Corners
                    where corner.HasColor(WHITE)
                    select FTLPair.GetPair(corner, FTLMoveCalculator.cube);

            FTLPair newPair = pairs.First(p => p == pair);

            void DoMove(CubeFace face, int count)
            {
                if (count == 0)
                {
                    return;
                }

                Move m = new Move(face, count);

                FTLMoveCalculator.cube.DoMove(m);
                moves.Add(m);
            }

            FTLMoveCalculator.DoMove += DoMove;

            CalcPairMoves(newPair);

            FTLMoveCalculator.DoMove -= DoMove;

            return(moves);
        }
コード例 #3
0
        public void TestVerwijderLijnVanKabel()
        {
            Kabel   kabel   = new Kabel();
            Lijn    lijn    = new Lijn();
            Sporter sporter = new Sporter(MoveCollection.GetWillekeurigeMoves())
            {
                Skies    = new Skies(),
                Zwemvest = new Zwemvest()
            };

            lijn.Sporter = sporter;
            lijn.Sporter.AantalRondenNogTeGaan = 1;
            kabel.NeemLijnInGebruik(lijn);
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();
            kabel.VerschuifLijnen();

            Lijn testLine = kabel.VerwijderLijnVanKabel();

            Assert.AreEqual(lijn, testLine);
        }
コード例 #4
0
 public void SporterStart_NoSKiesORvest_ThrowException()
 {
     //arrange
     Waterskibaan.Waterskibaan waterskibaan = new Waterskibaan.Waterskibaan();
     //assert
     Assert.Throws <Exception>(() => waterskibaan.SporterStart(new Sporter(MoveCollection.GetWillekeurigeMoves())));
     //TODO: add a Assert check for exceptions
 }
コード例 #5
0
        public void DebuggerDisplay_EmptyMoveCollection_AreEqual()
        {
            var moves = MoveCollection.CreateNoMoves();

            var act = moves.DebuggerDisplay;
            var exp = "No moves";

            Assert.AreEqual(exp, act);
        }
コード例 #6
0
ファイル: Board.cs プロジェクト: sodlum/Chess
        /// <summary>
        /// Creates new instance of chess board.
        /// </summary>
        /// <param name="start">Optional flag to immediately start chess game.</param>
        public Board(bool start = false)
        {
            Pieces     = new PieceCollection();
            Tiles      = new TileCollection();
            MovesTaken = new MoveCollection();

            if (start)
            {
                Start();
            }
        }
コード例 #7
0
        public override void StartThink(Board board, DiceRoll roll)
        {
            base.StartThink(board, roll);
            //Continue logic

            MoveCollection collection = board.GetMoves(roll, Team);

            if (collection.Count == 0)
            {
                base.SetMove(null);
            }
        }
コード例 #8
0
        public void TestVerschuifLijnen()
        {
            Kabel   kabel   = new Kabel();
            Lijn    lijn    = new Lijn();
            Sporter sporter = new Sporter(MoveCollection.GetWillekeurigeMoves());

            sporter.AantalRondenNogTeGaan = new Random().Next(1, 3);
            lijn.Sporter = sporter;
            kabel.NeemLijnInGebruik(lijn);
            kabel.VerschuifLijnen();

            Assert.AreEqual(kabel.IsStartPositieLeeg(), true);
        }
コード例 #9
0
ファイル: CubeSolver.cs プロジェクト: nicarb/Rubinator3000
        /// <summary>
        /// Erstellt einen neuen CubeSolver und eine Kopie des aktuellen Cubes
        /// </summary>
        /// <param name="cube">Der zu lösende Cube</param>
        public CubeSolver(Cube cube)
        {
            if (!CheckCube(cube))
            {
                throw new ArgumentException();
            }
#if DEBUG
            this.cube = cube;
#else
            this.cube = Utility.DeepClone(cube);
#endif
            moves = new MoveCollection();
        }
コード例 #10
0
        public void SporterStart_AllRequirements_SporteraddedToKabel()
        {
            //arrange
            Waterskibaan.Waterskibaan waterskibaan = new Waterskibaan.Waterskibaan();
            //act
            waterskibaan.SporterStart(new Sporter(MoveCollection.GetWillekeurigeMoves())
            {
                Skies = new Skies(), Zwemvest = new Zwemvest()
            });
            //assert
            int result = waterskibaan._kabel.Lijnen.Count;

            Assert.AreEqual(1, result);
        }
コード例 #11
0
        public void SporterNeemtPlaats_MoreSportersStartThenAllowed_listcountisfive()
        {
            //arrange
            InstructieGroep groep = new InstructieGroep();

            //act
            for (int i = 0; i < 10; i++)
            {
                groep.SporterNeemtPlaats(new Sporter(MoveCollection.GetWillekeurigeMoves()));
            }
            int listCount = groep.GetAantal();

            //assert
            Assert.AreEqual(5, listCount);
        }
コード例 #12
0
        public void TestMarbleOverlapping()
        {
            Position test = new Position(Board.EMPTY_BOARD);

            test.Set("b11", Board.YELLOW);
            test.Set("b12", Board.YELLOW);

            Board board = new Board();

            board.SetPosition(test);

            MoveCollection moves = board.GetMoves(new DiceRoll(2, 5), Board.YELLOW);

            Assert.IsTrue(moves.Count == 1);
        }
コード例 #13
0
        public void GetAlleSporters_FilledList_ListCountequalsReturnedList()
        {
            //arrange
            InstructieGroep groep = new InstructieGroep();

            //act
            for (int i = 0; i < 4; i++)
            {
                groep.SporterNeemtPlaats(new Sporter(MoveCollection.GetWillekeurigeMoves()));
            }
            int            orginalCount = groep.GetAantal();
            List <Sporter> newlist      = groep.GetAlleSporters();

            //assert
            Assert.AreEqual(orginalCount, newlist.Count);
        }
コード例 #14
0
        public void SportersVerlatenRij_FilledList_ListCountDecreases()
        {
            //arrange
            InstructieGroep groep = new InstructieGroep();

            //act
            for (int i = 0; i < 4; i++)
            {
                groep.SporterNeemtPlaats(new Sporter(MoveCollection.GetWillekeurigeMoves()));
            }
            groep.SportersVerlatenRij(3);
            int listCount = groep.GetAantal();

            //assert
            Assert.AreEqual(1, listCount);
        }
コード例 #15
0
        protected override void CalcMoves()
        {
            while (pairs.Any(pair => !pair.Solved))
            {
                var pairMoves = from pair in pairs
                                where !pair.Solved
                                select FTLMoveCalculator.CalcMoves(pair, cube);

                int            minMoves = pairMoves.Min(m => m.Count);
                MoveCollection moves    = pairMoves.First(e => e.Count == minMoves);

                cube.DoMoves(moves);
                this.moves.AddRange(moves);
            }

            movesCalculated = true;
        }
コード例 #16
0
        public void VerwijderLijnVanKabel_LastPositionFilled_ListCountDecreases()
        {
            //arrange
            Kabel kabel = new Kabel();

            for (int i = 0; i < 10; i++)
            {
                Lijn lijn = new Lijn(i);
                lijn.Sporter = new Sporter(MoveCollection.GetWillekeurigeMoves())
                {
                    AantalRondesTeGaan = 1
                };
                kabel.ToevoegenAanLijst(lijn);
            }
            //act
            Lijn testLijn = kabel.VerwijderLijnVanKabel();

            //assert
            Assert.IsNotNull(testLijn);
        }
コード例 #17
0
        protected override void SetStringValue(string value)
        {
            var entries = value.Split(':');

            if (!this.Validate(entries, $"Malformed movement event \"{value}\".", e => e.Length >= 3 && e[0] == "emove"))
            {
                return;
            }

            var newIsMapIndex = int.TryParse(entries[1], out int newMapIndex);
            var newObjectID   = entries[1];

            var newMoves = new MoveCollection {
                StringValue = string.Join(":", entries.Skip(2))
            };

            this.IsMapIndex = newIsMapIndex;
            this.MapIndex   = newMapIndex;
            this.ObjectID   = newObjectID;
            this.Moves      = newMoves;
        }
コード例 #18
0
        public void VerschuifLijnen_LaatstePositiegevuld_eerstepositieWordtgevuld()
        {
            //arrange
            Kabel kabel = new Kabel();

            for (int i = 0; i < 10; i++)
            {
                Lijn lijn = new Lijn(i);
                lijn.Sporter = new Sporter(MoveCollection.GetWillekeurigeMoves())
                {
                    AantalRondesTeGaan = 1
                };
                kabel.ToevoegenAanLijst(lijn);
            }
            //act
            kabel.VerschuifLijnen();
            int result    = kabel.Lijnen.First.Value.PositieOpDeLijn;
            int lastValue = kabel.Lijnen.Last.Value.PositieOpDeLijn;

            //assert
            Assert.AreEqual(0, result);
            Assert.AreEqual(9, lastValue);
        }
コード例 #19
0
        /// <summary>
        /// Creates a new instance of the Piece object.
        /// </summary>
        /// <param name="tile">The location that the Piece object will exist on the chess board.</param>
        /// <param name="team">The team that the Piece object will be on.</param>
        /// <param name="parent">The chess board.</param>
        public Piece(string tile, Team team, Board parent)
        {
            if (tile.Length == 2)
            {
                int i = 0;

                if (int.TryParse(tile[1].ToString(), out i))
                {
                    var c = tile[0];

                    if (c.IsBetween('A', 'H'))
                    {
                        Y = c;
                        X = i;
                    }
                    else
                    {
                        throw new InvalidTileException("Character parameter invalid for tile");
                    }
                }
                else
                {
                    throw new InvalidTileException("Number parameter invalid for tile");
                }
            }
            else
            {
                throw new InvalidTileException("Length parameter invalid for tile");
            }

            Team          = team;
            MovesTaken    = new MoveCollection();
            Parent        = parent;
            MovementRules = new Dictionary <string, Func <Move, bool> >();
            ID            = Guid.NewGuid();
            SetFlags      = true;
        }
コード例 #20
0
        public PerformMoveViewModel(
            ICommonDataManager commonDataManager,
            IServiceCallInvoker serviceCallInvoker,
            IMapService mapService,
            IMessageBoxDialogService messageBoxDialogService)
            : base(commonDataManager, serviceCallInvoker)
        {
            CommonDataManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "PlayerId")
                {
                    PlayerId = CommonDataManager.PlayerId;
                }
            };

            _mapService = mapService;
            _messageBoxDialogService = messageBoxDialogService;
            PlayerId = CommonDataManager.PlayerId;

            _mapService.MapChanged += (sender, args) =>
            {
                var cellViewModels = new List <CellViewModel>();

                for (int row = 0; row < _mapService.Height; row++)
                {
                    for (int col = 0; col < _mapService.Width; col++)
                    {
                        cellViewModels.Add(new CellViewModel
                        {
                            X     = col,
                            Y     = row,
                            State = _mapService.Map[row, col]
                        });
                    }
                }

                CellCollection = new ObservableCollection <CellViewModel>(cellViewModels);
                MoveCollection = new ObservableCollection <PlayerMoveModel>(_mapService.Actors.Select(a => new PlayerMoveModel
                {
                    Index    = a.Index,
                    Name     = a.Name,
                    Move     = a.Position,
                    IsTecman = a.IsTecman
                }));
            };

            _mapService.CellChanged += (sender, args) =>
            {
                var index = args.Y * _mapService.Width + args.X;
                CellCollection[index].State = args.State;
            };

            if (_mapService.Map != null)
            {
                var cellViewModels = new List <CellViewModel>();

                for (int row = 0; row < _mapService.Height; row++)
                {
                    for (int col = 0; col < _mapService.Width; col++)
                    {
                        cellViewModels.Add(new CellViewModel
                        {
                            X     = col,
                            Y     = row,
                            State = _mapService.Map[row, col]
                        });
                    }
                }

                CellCollection = new ObservableCollection <CellViewModel>(cellViewModels);
                MoveCollection = new ObservableCollection <PlayerMoveModel>(_mapService.Actors.Select(a => new PlayerMoveModel
                {
                    Index    = a.Index,
                    Name     = a.Name,
                    Move     = a.Position,
                    IsTecman = a.IsTecman
                }));
            }
            else
            {
                CellCollection = new ObservableCollection <CellViewModel>();
                MoveCollection = new ObservableCollection <PlayerMoveModel>();
            }

            this.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedCell")
                {
                    if (SelectedCell != null && SelectedActor != null)
                    {
                        SelectedActor.Move = new Point(SelectedCell.Y, SelectedCell.X);
                        Positions          = string.Concat(MoveCollection.Select(m => $"{m.Move.Row},{m.Move.Col},"));
                    }
                }
            };
        }
コード例 #21
0
        public void TestSporterStart()
        {
            Waterskibaan.Waterskibaan waterskibaan = new Waterskibaan.Waterskibaan();

            waterskibaan.SporterStart(new Sporter(MoveCollection.GetWillekeurigeMoves()));
        }
コード例 #22
0
 /// <summary>
 /// Creates or updates a move collection.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The Resource Group Name.
 /// </param>
 /// <param name='moveCollectionName'>
 /// The Move Collection Name.
 /// </param>
 /// <param name='body'>
 /// </param>
 public static MoveCollection Create(this IMoveCollectionsOperations operations, string resourceGroupName, string moveCollectionName, MoveCollection body = default(MoveCollection))
 {
     return(operations.CreateAsync(resourceGroupName, moveCollectionName, body).GetAwaiter().GetResult());
 }
コード例 #23
0
 /// <summary>
 /// Creates or updates a move collection.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The Resource Group Name.
 /// </param>
 /// <param name='moveCollectionName'>
 /// The Move Collection Name.
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <MoveCollection> CreateAsync(this IMoveCollectionsOperations operations, string resourceGroupName, string moveCollectionName, MoveCollection body = default(MoveCollection), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, moveCollectionName, body, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }