PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/DataAccess.DatabaseTests/SqlServerFunctionTests.cs

#
C# | 58 lines | 52 code | 6 blank | 0 comment | 0 complexity | 4cddccfa55d19fa432fbcd53b5643f27 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using DataAccess.DatabaseTests.Tests;
  6. using DataAccess.Core.Interfaces;
  7. using DataAccess.SqlServer;
  8. using Xunit;
  9. using DataAccess.Core.Schema;
  10. using DataAccess.DatabaseTests.DataObjects;
  11. using Microsoft.SqlServer.Types;
  12. namespace DataAccess.DatabaseTests
  13. {
  14. public class SqlServerFunctionTests : FunctionTests
  15. {
  16. public override IDataStore GetDataStore()
  17. {
  18. return SqlServerConnection.GetDataStore("Data Source=sql;Initial Catalog=Sauce;User Id=AppLogin;Password=AppLogin;");
  19. }
  20. public override void Test_Can_Get_Escape_Sequences()
  21. {
  22. Assert.True(dstore.Connection.LeftEscapeCharacter.Equals("["));
  23. Assert.True(dstore.Connection.RightEscapeCharacter.Equals("]"));
  24. }
  25. [Fact]
  26. public void Test_TSql_Lower_Than_Min_Date_Returns_Null()
  27. {
  28. SqlServerTypeConverter tConverter = new SqlServerTypeConverter();
  29. object result = tConverter.ConvertToType<DateTime?>(DateTime.MinValue);
  30. Assert.Null(result);
  31. }
  32. [Fact]
  33. public void Test_Can_Insert_Spacial_Type()
  34. {
  35. Assert.True(dstore.InsertObject(new TestItemWithGeography()
  36. {
  37. Location = SqlGeography.Point(1, 1, 4326)
  38. }));
  39. }
  40. [Fact]
  41. public void Test_Can_CRUD_Spacial_Type()
  42. {
  43. Assert.True(dstore.InsertObject(new TestItemWithGeography()
  44. {
  45. Location = SqlGeography.Point(1, 1, 4326)
  46. }));
  47. TestItemWithGeography loaded = dstore.LoadObject<TestItemWithGeography>(1);
  48. Assert.NotNull(loaded);
  49. Assert.NotNull(loaded.Location);
  50. }
  51. }
  52. }