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); }
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); }
public void ShouldDeserializeDecimalAsString(string value) { var row = BuildRow(1, ("Price", new TpsDecimal(value))); var des = row.Deserialize <DecimalStringModel>(); Assert.AreEqual(value, des.Price); }
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); }
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); }
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); }
public void ShouldDeserializeLong() { var row = BuildRow(1, ("Count", new TpsLong(12))); var deserialized = row.Deserialize <LongModel>(); Assert.AreEqual(12, deserialized.Count); }
public void ShouldUseFallbackDeserializingNullDate() { var row = BuildRow(1, ("Date", new TpsDate((DateTime?)null))); var deserialized = row.Deserialize <DateStringFallbackModel>(); Assert.AreEqual("nothing", deserialized.Date); }
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); }
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); }
public void ShouldDeserializeAndTrimString() { var row = BuildRow(1, ("Notes", new TpsPString(" Hello world! "))); var deserialized = row.Deserialize <StringTrimmingEnabledModel>(); Assert.AreEqual(" Hello world!", deserialized.Notes); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
// ---- 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); }
// ---- 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()); }
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(); }
public void ShouldThrowWhenDeserializing(TpsObject tpsObject) { var row = BuildRow(1, ("Count", tpsObject)); Assert.Throws <TpsParserException>(() => row.Deserialize <LongModel>()); }
public void ShouldThrowDeserializingDateStringToNonStringMember() { var row = BuildRow(1, ("Date", new TpsDate(new DateTime(2019, 7, 17)))); Assert.Throws <TpsParserException>(() => row.Deserialize <DateStringNonStringMemberModel>()); }