PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/UnitTests/DS_StaticMethods.cs

http://github.com/fredericaltorres/DynamicSugarNet
C# | 61 lines | 51 code | 8 blank | 2 comment | 0 complexity | 74ad0475a0615fabe61350110554c6fe MD5 | raw file
  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using DynamicSugar;
  7. using System.Dynamic;
  8. using System.Linq.Expressions;
  9. namespace DynamicSugarSharp_UnitTests {
  10. //TODO:Try extension method to List<T>
  11. [TestClass]
  12. public class DS_StaticMethods_UnitTests {
  13. private string InitializeSettings(IDictionary<string, object> settings){
  14. return settings["UserName"].ToString();
  15. }
  16. [TestMethod]
  17. public void DS_Dictionary(){
  18. Assert.AreEqual("RRabbit",
  19. InitializeSettings( DS.Dictionary(
  20. new {
  21. UserName = "RRabbit" ,
  22. Domain = "ToonTown",
  23. UserID = 234873
  24. }
  25. ))
  26. );
  27. }
  28. [TestMethod]
  29. public void DS_Values(){
  30. var bag = DS.Values( new { a=1, b=2, c=3 } );
  31. Assert.AreEqual(1,bag.a);
  32. Assert.AreEqual(2,bag.b);
  33. Assert.AreEqual(3,bag.c);
  34. }
  35. [TestMethod]
  36. public void DS_Values_PassInFunctionAsIDictionary(){
  37. // Dynamic Sugar syntaxes
  38. InitializeSettings( DS.Values( new {
  39. UserName= "RRabbit" ,
  40. Domain = "ToonTown",
  41. UserID = 234873
  42. }));
  43. Assert.AreEqual("RRabbit",
  44. InitializeSettings( DS.Values(new {
  45. UserName = "RRabbit" ,
  46. Domain = "ToonTown",
  47. UserID = 234873
  48. }
  49. ))
  50. );
  51. }
  52. }
  53. }