public void Insert(IMapedFrame frame, Guid playerId, Guid gameId) { Parameters.Clear(); Command = "InsertFrame"; Parameters.Add(ParameterFactory.Create("PlayerId", DbType.Guid, playerId)); Parameters.Add(ParameterFactory.Create("GameId", DbType.Guid, gameId)); Parameters.Add(ParameterFactory.Create("FrameId", DbType.Int32, frame.Index)); Parameters.Add(ParameterFactory.Create("Try1", DbType.Int32, frame.Try1)); Parameters.Add(ParameterFactory.Create("Try2", DbType.Int32, frame.Try2)); Parameters.Add(ParameterFactory.Create("Bonus", DbType.Int32, frame.BonusScore)); Parameters.Add(ParameterFactory.Create("IsStrike", DbType.Boolean, frame.IsStrike)); Parameters.Add(ParameterFactory.Create("IsSpare", DbType.Boolean, frame.IsSpare)); Parameters.Add(ParameterFactory.Create("TotalScore", DbType.Int32, frame.TotalScore)); Parameters.Add(ParameterFactory.Create("CumulativeScore", DbType.Int32, frame.CumulativeTotalScore)); ExecuteTask(Insert); }
public void Should_allow_null_strings() { var parameter = _parameterFactory.Create("param1", (string)null, ParameterDirection.Input); Assert.AreEqual(SqlDbType.VarChar, parameter.DbType); Assert.AreEqual(ParameterDirection.Input, parameter.Direction); Assert.AreEqual("param1", parameter.Name); Assert.AreEqual(typeof(string), parameter.Type); Assert.IsNull(parameter.Value); }
public void Get(string messageName) { Parameters.Clear(); Command = "GetMessage"; Parameters.Add(ParameterFactory.Create("@MessageName", DbType.AnsiString, messageName)); Parameters.Add(ParameterFactory.Create("@RetId", DbType.AnsiString, MessageValue, 50, ParameterDirection.Output)); ExecuteTask(Get); }
public void Get(string playerName) { Parameters.Clear(); Command = "GetPlayer"; Parameters.Add(ParameterFactory.Create("@PlayerName", DbType.AnsiString, playerName)); Parameters.Add(ParameterFactory.Create("@RetId", DbType.Guid, PlayerId, ParameterDirection.Output)); ExecuteTask(Get); }
public void Insert(string gameType, DateTime currentDateTime, Guid Id) { Command = "INSERT INTO Games (Id, GameType, GameDateTime) VALUES (@Id, @GameType, @GameDateTime)"; Parameters.Add(ParameterFactory.Create("Id", DbType.Guid, Id)); Parameters.Add(ParameterFactory.Create("GameType", DbType.AnsiString, gameType)); Parameters.Add(ParameterFactory.Create("GameDateTime", DbType.DateTime, currentDateTime)); ExecuteTask(Insert); }
public void Insert(string playerName, Guid PlayerId) { Parameters.Clear(); Command = "InsertPlayer"; Parameters.Add(ParameterFactory.Create("@id", DbType.Guid, PlayerId)); Parameters.Add(ParameterFactory.Create("@PlayerName", DbType.AnsiString, playerName)); ExecuteTask(Insert); }
public void ParameterUnit_DeviceUnitSetWithEnumeratedUnitType_DeviceUnitTypeReturnsValidValue() { // arrange IParameter parameter = ParameterFactory.Create("dummy", ParameterType.Enumerated); // act var unit = new ParameterUnit { DeviceUnit = parameter, }; // assert Assert.AreEqual(ParameterUnitType.Enumerated, unit.DeviceUnitType); }
public void ParameterUnit_DeviceUnitSet_ReturnsValidValue() { // arrange IParameter parameter = ParameterFactory.Create("dummy"); // act var unit = new ParameterUnit { DeviceUnit = parameter, }; // assert Assert.AreEqual(parameter, unit.DeviceUnit); }
public void ParameterUnit_DeviceUnitIsUpdated_DeviceUnitChangedContainsValidSender() { // arrange var parameter = new ParameterUnit(); object sender = null; parameter.DeviceUnitChanged += (s, e) => { sender = s; }; // act parameter.DeviceUnit = ParameterFactory.Create("dummy"); // assert Assert.AreEqual(sender, parameter); }
public void ParameterUnit_DeviceUnitIsUpdated_DeviceUnitChangedIsRaised() { // arrange var parameter = new ParameterUnit(); bool eventRaised = false; parameter.DeviceUnitChanged += (s, e) => { eventRaised = true; }; // act parameter.DeviceUnit = ParameterFactory.Create("dummy"); // assert Assert.IsTrue(eventRaised); }
public void Insert(Guid gameId, Guid playerId, string gameType, int score) { Parameters.Clear(); Command = "InsertUpdateScores"; Parameters.Add(ParameterFactory.Create("@id", DbType.Guid, playerId)); Parameters.Add(ParameterFactory.Create("@GameId", DbType.Guid, gameId)); Parameters.Add(ParameterFactory.Create("@GameType", DbType.AnsiString, gameType)); Parameters.Add(ParameterFactory.Create("@Score", DbType.Int32, score)); ExecuteTask(Insert); }
public void ParameterUnit_ConstantUnitUpdatedWhenDeviceUnitSet_DeviceUnitChangedIsNotRaised() { // arrange var parameter = new ParameterUnit { DeviceUnit = ParameterFactory.Create("dummy"), }; bool eventRaised = false; parameter.DeviceUnitChanged += (s, e) => { eventRaised = true; }; // act parameter.ConstantUnit = "dummy"; // assert Assert.IsFalse(eventRaised); }
public void ParameterUnit_DeviceUnitWithNullValueUpdatedWhenDisposed_DeviceUnitChangedIsNotRaised() { // arrange var parameter = new ParameterUnit { DeviceUnit = null, }; bool eventRaised = false; parameter.DeviceUnitChanged += (s, e) => { eventRaised = true; }; parameter.Dispose(); // act parameter.DeviceUnit = ParameterFactory.Create("dummy"); // assert Assert.IsFalse(eventRaised); }
public void UpdateFrame(IMapedFrame frame, Guid playerId, Guid gameId) { Parameters.Clear(); Command = "UpdateFrame"; Parameters.Add(ParameterFactory.Create("PlayerId", DbType.Guid, playerId)); Parameters.Add(ParameterFactory.Create("GameId", DbType.Guid, gameId)); Parameters.Add(ParameterFactory.Create("FrameId", DbType.Int32, frame.Index)); Parameters.Add(ParameterFactory.Create("Bonus", DbType.Int32, frame.BonusScore)); Parameters.Add(ParameterFactory.Create("TotalScore", DbType.Int32, frame.TotalScore)); Parameters.Add(ParameterFactory.Create("CumulativeScore", DbType.Int32, frame.CumulativeTotalScore)); ExecuteTask(Update); }
public static IMethodArgument Create(ITestCaseCell cell, MethodArgType placement) { if (placement == MethodArgType.Parameter) { return(new StringParameter(cell.Value.ToString(), placement)); } var v = cell.Value.ToString().Trim(); if (v.StartsWith("'", StringComparison.OrdinalIgnoreCase) && v.EndsWith("'", StringComparison.OrdinalIgnoreCase)) { return(new StringParameter( cell.Value.ToString(), placement)); } var isNullable = v.EndsWith("?"); if (isNullable) { v = v.Substring(0, v.Length - 1); } try { checked { var param = ParameterFactory.Create(v, isNullable); if (param.IsValid()) { return(param); } return(new StringParameter(v, placement)); } } catch (FormatException) { return(new StringParameter(v, placement)); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { } if (isNullable) { return(new NumericNull()); } try { return(new NumericParameter(v)); } // ReSharper disable once EmptyGeneralCatchClause catch { } return(new StringParameter(v, placement)); }