public void Format_Variable_Test() { // Arrange var input = new Variable("ABCD"); // Act object result = this.formatter.Format(input); // Assert Assert.AreEqual("@ABCD", result); }
public void GetRegularColumns_WriteGuid_Test() { // Arrange var table = new ClassWithGuidKeys(); Mock<ITypeGenerator> typeGeneratorMock = Helpers.GetTypeGeneratorMock(table); var recordReference = new RecordReference<ClassWithGuidKeys>(typeGeneratorMock.Object, this.attributeDecorator); recordReference.Populate(); var insertRecordService = new InsertRecordService(recordReference, this.attributeDecorator, InsertRecordServiceTest.IsKeyReferenceCheckEnforced); Variable v1, v2, v3; this.writerMock.Setup(m => m.WriteGuid("Key1")).Returns(v1 = new Variable("x")); this.writerMock.Setup(m => m.WriteGuid("Key3")).Returns(v2 = new Variable("y")); this.writerMock.Setup(m => m.WriteGuid("Key4")).Returns(v3 = new Variable("z")); // Act List<Column> regularColumns = insertRecordService.GetRegularColumns(this.writerMock.Object).ToList(); // Assert this.writerMock.Verify(m => m.WriteGuid(It.IsAny<string>()), Times.Exactly(3)); Column key1 = regularColumns.First(c => c.Name == "Key1"); Column key3 = regularColumns.First(c => c.Name == "Key3"); Column key4 = regularColumns.First(c => c.Name == "Key4"); Assert.AreEqual(v1, key1.Value); Assert.AreEqual(v2, key3.Value); Assert.AreEqual(v3, key4.Value); }
public override object SelectIdentity(string columnName) { SqlClientWritePrimitives.Logger.Debug($"Entering SelectIdentity. columnName: {columnName}"); string symbol = this.symbolGenerator.GetRandomString(10); SqlClientWritePrimitives.Logger.Debug($"symbol: {symbol}"); this.ExecutionStatements.AppendLine($"declare @{symbol} bigint;"); this.ExecutionStatements.AppendLine($"select @{symbol} = @@identity;"); this.ExecutionStatements.AppendLine($"select '{columnName}'"); this.ExecutionStatements.AppendLine($"select @{symbol}"); this.ExecutionStatements.AppendLine(); var result = new Variable(symbol); SqlClientWritePrimitives.Logger.Debug($"Exiting SelectIdentity"); return result; }
public override object WriteGuid(string columnName) { SqlClientWritePrimitives.Logger.Debug($"Entering WriteGuid. columnName: {columnName}"); string symbol = this.symbolGenerator.GetRandomString(10); SqlClientWritePrimitives.Logger.Debug($"symbol: {symbol}"); this.ExecutionStatements.AppendLine($"declare @{symbol} uniqueidentifier;"); this.ExecutionStatements.AppendLine($"select @{symbol} = NEWID();"); this.ExecutionStatements.AppendLine($"select '{columnName}'"); this.ExecutionStatements.AppendLine($"select @{symbol}"); this.ExecutionStatements.AppendLine(); var result = new Variable(symbol); SqlClientWritePrimitives.Logger.Debug($"Exiting WriteGuid"); return result; }