public void JsonSerialiser_WriteObject_Writes_ValueTypes_Correctly_For_Non_UK_Cultures() { var worksheet = new ExcelWorksheetData(TestContext); foreach (var culture in new string[] { "en-US", "de-DE", "fr-FR", "ru-RU" }) { using (var cultureSwitcher = new CultureSwitcher(culture)) { TestCleanup(); TestInitialise(); var obj = new ValueTypes() { BoolValue = worksheet.Bool("BoolValue"), UnusedBool = worksheet.Bool("UnusedBool"), NullableBool = worksheet.NBool("NullableBool"), Int = worksheet.Int("Int"), NullableInt = worksheet.NInt("NullableInt"), Long = worksheet.Long("Long"), NullableLong = worksheet.NLong("NullableLong"), Float = worksheet.Float("Float"), NullableFloat = worksheet.NFloat("NullableFloat"), Double = worksheet.Double("Double"), NullableDouble = worksheet.NDouble("NullableDouble"), DateTime = worksheet.DateTime("DateTime"), NullableDateTime = worksheet.NDateTime("NullableDateTime"), }; _JsonSerialiser.Initialise(typeof(ValueTypes)); _JsonSerialiser.WriteObject(_Stream, obj); var message = String.Format("when culture is {0}", culture); Assert.AreEqual(worksheet.EString("Json"), GetJson(), message); } } }
public void JsonSerialiser_WriteObject_Writes_ValueTypes_Correctly() { var worksheet = new ExcelWorksheetData(TestContext); var obj = new ValueTypes() { BoolValue = worksheet.Bool("BoolValue"), UnusedBool = worksheet.Bool("UnusedBool"), NullableBool = worksheet.NBool("NullableBool"), Int = worksheet.Int("Int"), NullableInt = worksheet.NInt("NullableInt"), Long = worksheet.Long("Long"), NullableLong = worksheet.NLong("NullableLong"), Float = worksheet.Float("Float"), NullableFloat = worksheet.NFloat("NullableFloat"), Double = worksheet.Double("Double"), NullableDouble = worksheet.NDouble("NullableDouble"), DateTime = worksheet.DateTime("DateTime"), NullableDateTime = worksheet.NDateTime("NullableDateTime"), }; _JsonSerialiser.Initialise(typeof(ValueTypes)); _JsonSerialiser.WriteObject(_Stream, obj); Assert.AreEqual(worksheet.EString("Json"), GetJson()); }
public void FlightSimulatorXPresenter_RidingAircraft_Sends_Real_World_Aircraft_Information_To_FSX_On_View_Timer_Tick() { var worksheet = new ExcelWorksheetData(TestContext); _Presenter.Initialise(_View.Object); _Provider.Setup(p => p.UtcNow).Returns(worksheet.DateTime("UtcNow")); _SelectedAircraft.UniqueId = 92; var aircraft = new Mock<IAircraft>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _RealAircraftList.Add(aircraft.Object); aircraft.Object.UniqueId = 92; aircraft.Object.Latitude = worksheet.NFloat("Latitude"); aircraft.Object.Longitude = worksheet.NFloat("Longitude"); aircraft.Object.PositionTime = worksheet.NDateTime("PositionTime"); aircraft.Object.GroundSpeed = worksheet.NFloat("GroundSpeed"); aircraft.Object.Track = worksheet.NFloat("Track"); aircraft.Object.Type = worksheet.String("Type"); aircraft.Object.Model = worksheet.String("Model"); aircraft.Object.Operator = worksheet.String("Operator"); aircraft.Object.Registration = worksheet.String("Registration"); aircraft.Object.Squawk = worksheet.NInt("Squawk"); aircraft.Object.Altitude = worksheet.NInt("Altitude"); aircraft.Object.VerticalRate = worksheet.NInt("VerticalRate"); WriteAircraftInformation aircraftInformation = new WriteAircraftInformation(); _FlightSimulatorX.Setup(f => f.MoveAircraft(It.IsAny<WriteAircraftInformation>())).Callback((WriteAircraftInformation writeAircraftInformation) => { aircraftInformation = writeAircraftInformation; }); _FlightSimulatorX.Setup(f => f.Connected).Returns(true); _FlightSimulatorX.Raise(f => f.ConnectionStatusChanged += null, EventArgs.Empty); _View.Raise(v => v.RideAircraftClicked += null, EventArgs.Empty); _View.Raise(v => v.RefreshFlightSimulatorXInformation += null, EventArgs.Empty); _FlightSimulatorX.Verify(f => f.MoveAircraft(It.IsAny<WriteAircraftInformation>()), Times.Once()); Assert.AreEqual(worksheet.Double("FSXAirspeedIndicated"), aircraftInformation.AirspeedIndicated); Assert.AreEqual(worksheet.Double("FSXAltitude"), aircraftInformation.Altitude); Assert.AreEqual(worksheet.Double("FSXLatitude"), aircraftInformation.Latitude, 0.001); Assert.AreEqual(worksheet.Double("FSXLongitude"), aircraftInformation.Longitude, 0.001); Assert.AreEqual(worksheet.String("FSXOperator"), aircraftInformation.Operator); Assert.AreEqual(worksheet.String("FSXRegistration"), aircraftInformation.Registration); Assert.AreEqual(worksheet.Double("FSXTrueHeading"), aircraftInformation.TrueHeading, 0.001); Assert.AreEqual(worksheet.Double("FSXVerticalSpeed"), aircraftInformation.VerticalSpeed); }
public void JsonSerialiser_WriteObject_Writes_ValueTypes_Correctly_For_Non_UK_Cultures() { var worksheet = new ExcelWorksheetData(TestContext); foreach(var culture in new string[] { "en-US", "de-DE", "fr-FR", "ru-RU" }) { using(var cultureSwitcher = new CultureSwitcher(culture)) { TestCleanup(); TestInitialise(); var obj = new ValueTypes() { BoolValue = worksheet.Bool("BoolValue"), UnusedBool = worksheet.Bool("UnusedBool"), NullableBool = worksheet.NBool("NullableBool"), Int = worksheet.Int("Int"), NullableInt = worksheet.NInt("NullableInt"), Long = worksheet.Long("Long"), NullableLong = worksheet.NLong("NullableLong"), Float = worksheet.Float("Float"), NullableFloat = worksheet.NFloat("NullableFloat"), Double = worksheet.Double("Double"), NullableDouble = worksheet.NDouble("NullableDouble"), DateTime = worksheet.DateTime("DateTime"), NullableDateTime = worksheet.NDateTime("NullableDateTime"), }; _JsonSerialiser.Initialise(typeof(ValueTypes)); _JsonSerialiser.WriteObject(_Stream, obj); var message = String.Format("when culture is {0}", culture); Assert.AreEqual(worksheet.EString("Json"), GetJson(), message); } } }