예제 #1
0
        public void TestAmmendSpecificationMapsAllAliasesToExpectedNativeTypesOnEmptySpec()
        {
            // arrange
            var spec = new Spec {
                Targets = new Dictionary <string, TargetInfo> {
                    { Constants.CSharpTarget, new TargetInfo() }
                }
            };
            var ammendment = new CSharpAmmendment();

            // act
            ammendment.AmmedSpecification(spec);

            // assert
            var typeAliases = spec.Targets[Constants.CSharpTarget].TypeAliases.ToList();

            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("bool", "bool")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("char", "char")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("byte", "byte")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("short", "short")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("int", "int")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("long", "long")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("float", "float")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("double", "double")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("decimal", "decimal")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("string", "string")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("object", "object")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("time", "TimeSpan")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("date", "DateTime")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("datetime", "DateTimeOffset")));
            Assert.True(typeAliases.Remove(new KeyValuePair <string, string>("guid", "Guid")));
            Assert.True(typeAliases.Count == 0, "Additional TypeAliases present than those that were tested. Adjust your unit test.");
        }
예제 #2
0
        public void TestAmmendSpecificationFailsToReplaceBuiltinTypes()
        {
            // arrange
            var spec =
                new Spec
            {
                Targets = new Dictionary <string, TargetInfo>
                {
                    { Constants.CSharpTarget,
                      new TargetInfo
                      {
                          TypeAliases = new Dictionary <string, string>
                          {
                              { "datetime", "DateTime" }
                          }
                      } }
                }
            };

            var ammendment = new CSharpAmmendment();
            var exception  = (Exception)null;

            // act
            try { ammendment.AmmedSpecification(spec); } catch (Exception ex) { exception = ex; }

            // assert
            Assert.NotNull(exception);
        }