コード例 #1
0
            public void ShouldDeserializeDecimalAsTpsBooleanField(string value, bool expected)
            {
                var row = BuildRow(1, ("Price", new TpsDecimal(value)));
                var des = row.Deserialize <DecimalTpsBooleanFieldModel>();

                Assert.AreEqual(expected, des.Price);
            }
コード例 #2
0
            public void ShouldDeserializeDecimalAsNullableSByte(string value, sbyte?expected)
            {
                var row = BuildRow(1, ("Price", new TpsDecimal(value)));
                var des = row.Deserialize <DecimalNullableSByteModel>();

                Assert.AreEqual(expected, des.Price);
            }
コード例 #3
0
            public void ShouldDeserializeDecimalAsString(string value)
            {
                var row = BuildRow(1, ("Price", new TpsDecimal(value)));
                var des = row.Deserialize <DecimalStringModel>();

                Assert.AreEqual(value, des.Price);
            }
コード例 #4
0
            public void ShouldDeserializeDecimalAsInt(string value, int expected)
            {
                var row = BuildRow(1, ("Price", new TpsDecimal(value)));
                var des = row.Deserialize <DecimalIntModel>();

                Assert.AreEqual(expected, des.Price);
            }
コード例 #5
0
            public void ShouldDeserializeStringAsBooleanTpsBooleanFieldAttribute(string value, bool expected)
            {
                var row = BuildRow(1, ("Notes", new TpsString(value)));

                var des = row.Deserialize <StringBooleanModel>();

                Assert.AreEqual(expected, des.HasNotes);
            }
コード例 #6
0
            public void ShouldDeserializeStringAsBooleanFallbackDefault(string value, bool expected)
            {
                var row = BuildRow(1, ("Notes", new TpsCString(value)));

                var des = row.Deserialize <StringBooleanTrueFalseModel>();

                Assert.AreEqual(expected, des.HasNotes);
            }
コード例 #7
0
            public void ShouldDeserializeLong()
            {
                var row = BuildRow(1, ("Count", new TpsLong(12)));

                var deserialized = row.Deserialize <LongModel>();

                Assert.AreEqual(12, deserialized.Count);
            }
コード例 #8
0
            public void ShouldUseFallbackDeserializingNullDate()
            {
                var row = BuildRow(1, ("Date", new TpsDate((DateTime?)null)));

                var deserialized = row.Deserialize <DateStringFallbackModel>();

                Assert.AreEqual("nothing", deserialized.Date);
            }
コード例 #9
0
            public void ShouldSetDefaultWhenDeserializingNullDateIntoNonNullableDate()
            {
                var row = BuildRow(1, ("Date", new TpsDate(new RandomAccess(new byte[] { 0, 0, 0, 0 }))));

                var deserialized = row.Deserialize <DateModel>();

                Assert.AreEqual(default(DateTime), deserialized.Date);
            }
コード例 #10
0
            public void ShouldDeserializeStringAsBooleanTrueCondition(string value, bool expected)
            {
                var row = BuildRow(1, ("Notes", new TpsPString(value)));

                var des = row.Deserialize <StringBooleanTrueModel>();

                Assert.AreEqual(expected, des.HasNotes);
            }
コード例 #11
0
            public void ShouldDeserializeAndTrimString()
            {
                var row = BuildRow(1, ("Notes", new TpsPString(" Hello world!     ")));

                var deserialized = row.Deserialize <StringTrimmingEnabledModel>();

                Assert.AreEqual(" Hello world!", deserialized.Notes);
            }
コード例 #12
0
            public void ShouldDeserializeNullDate()
            {
                var row = BuildRow(1, ("Date", new TpsDate(new RandomAccess(new byte[] { 0, 0, 0, 0 }))));

                var deserialized = row.Deserialize <NullDateModel>();

                Assert.IsNull(deserialized.Date);
            }
コード例 #13
0
            public void ShouldDeserializeTime()
            {
                var time = new TimeSpan(12, 13, 42);

                var row = BuildRow(1, ("Time", new TpsTime(time)));

                var deserialized = row.Deserialize <TimeModel>();

                Assert.AreEqual(time, deserialized.Time);
            }
コード例 #14
0
            public void ShouldDeserializeDateStringFormatted()
            {
                var expected = new DateTime(2019, 7, 17);

                var row = BuildRow(1, ("Date", new TpsDate(expected)));

                var deserialized = row.Deserialize <DateStringFormattedModel>();

                Assert.AreEqual(expected.ToString("MM - dd - yyyy"), deserialized.Date);
            }
コード例 #15
0
            public void ShouldDeserializeDate()
            {
                var date = new DateTime(2019, 7, 17);

                var row = BuildRow(1, ("Date", new TpsDate(date)));

                var deserialized = row.Deserialize <DateModel>();

                Assert.AreEqual(date, deserialized.Date);
            }
コード例 #16
0
            public void ShouldDeserializeTimeFromLong()
            {
                int centiseconds = 80085;

                var row = BuildRow(1, ("Time", new TpsLong(centiseconds)));

                var deserialized = row.Deserialize <TimeModel>();

                Assert.AreEqual(new TimeSpan(0, 0, 13, 20, 850), deserialized.Time);
            }
コード例 #17
0
            public void ShouldDeserializeAndNotTrimString()
            {
                string expected = " Hello world!     ";

                var row = BuildRow(1, ("Notes", new TpsPString(expected)));

                var deserialized = row.Deserialize <StringTrimmingDisabledModel>();

                Assert.AreEqual(expected, deserialized.Notes);
            }
コード例 #18
0
            public void ShouldDeserializeDateFromDecimal()
            {
                int clarionStandardDate = 80085;

                var row = BuildRow(1, ("Date", new TpsDecimal(clarionStandardDate.ToString())));

                var deserialized = row.Deserialize <DateModel>();

                Assert.AreEqual(new DateTime(2020, 4, 3), deserialized.Date);
            }
コード例 #19
0
            public void ShouldDeserializeString()
            {
                string expected = " Hello world!     ";

                var row = BuildRow(1, ("Notes", new TpsCString(expected)));

                var deserialized = row.Deserialize <StringModel>();

                Assert.AreEqual(expected, deserialized.Notes);
            }
コード例 #20
0
        // ---- Get/check state methods ----

        /**
         * Returns a TileCollection representing the tiles currently on the given build row
         *
         * @param row
         *            the build row
         * @return a TileCollection representing the tiles currently on the given build row
         */
        public TileCollection getBuildRowTiles(int row)
        {
            TileCollection tc = new TileCollection();
            BuildRow       br = buildRows[row];

            tc.addTiles(br.color, br.count);
            return(tc);
        }
コード例 #21
0
        // ---- Private methods ----

        /**
         * Tiles a build row onto the wall (if it's complete) and returns the discarded tiles from doing so
         *
         * @param row
         *            the row index to evaluate
         * @return any discarded tiles
         */
        private TileCollection tileRow(int row)
        {
            BuildRow br = buildRows[row];

            if (br.isFull())
            {
                wall[row, br.column()] = true;
                scoreTile(row, br.column());
                return(br.getDiscard());
            }
            return(new TileCollection());
        }
コード例 #22
0
        public PlayerBoard(Game m, string name)
        {
            model     = m;
            player    = name;
            wall      = new bool[5, 5];
            score     = 0;
            buildRows = new BuildRow[5];
            for (int i = 0; i < 5; ++i)
            {
                buildRows[i] = new BuildRow(this, i);
            }
            floorLine = new TileCollection();
            InitializeComponent();
            SuspendLayout();
            Icon            = Properties.Resources.icon;
            Text            = name;
            BackgroundImage = Properties.Resources.PlayerBoard;
            //TODO controls setup

            // 5 build rows plus floor line ( TODO onClick events )
            buildRowButtons = new Button[6];
            for (int i = 0; i < 5; ++i)
            {
                buildRowButtons[i] = new Button()
                {
                    UseVisualStyleBackColor = false,
                    FlatStyle = FlatStyle.Flat,
                    BackColor = System.Drawing.Color.FromArgb(0)
                };
                buildRowButtons[i].FlatAppearance.BorderSize = 0;
                buildRowButtons[i].SetBounds(BUILD_ROW_X_POS + (BUILD_ROW_X_OFFSET * i),
                                             BUILD_ROW_Y_POS + (BUILD_ROW_Y_OFFSET * i), 60 + (BUILD_ROW_X_OFFSET * -i), 60);
                Controls.Add(buildRowButtons[i]);
                buildRowButtons[i].BringToFront();
                buildRowButtons[i].Tag    = i;
                buildRowButtons[i].Click += new EventHandler(addTilesToRow);
            }
            buildRowButtons[5] = new Button()
            {
                UseVisualStyleBackColor = false,
                FlatStyle = FlatStyle.Flat,
                BackColor = System.Drawing.Color.FromArgb(0)
            };
            buildRowButtons[5].FlatAppearance.BorderSize = 0;
            buildRowButtons[5].SetBounds(FLOOR_X_POS, FLOOR_Y_POS, 60 + (FLOOR_X_OFFSET * 6), 60);
            Controls.Add(buildRowButtons[5]);
            buildRowButtons[5].BringToFront();
            buildRowButtons[5].Tag    = 5;
            buildRowButtons[5].Click += new EventHandler(addTilesToRow);
            updateButtons();
            ResumeLayout();
        }
コード例 #23
0
            public void ShouldThrowWhenDeserializing(TpsObject tpsObject)
            {
                var row = BuildRow(1, ("Count", tpsObject));

                Assert.Throws <TpsParserException>(() => row.Deserialize <LongModel>());
            }
コード例 #24
0
            public void ShouldThrowDeserializingDateStringToNonStringMember()
            {
                var row = BuildRow(1, ("Date", new TpsDate(new DateTime(2019, 7, 17))));

                Assert.Throws <TpsParserException>(() => row.Deserialize <DateStringNonStringMemberModel>());
            }