Ejemplo n.º 1
0
        public void GivenValidInput_Generate_ShouldReturnCSCode(string filename)
        {
            // Arrange
            var generator = new CodeGenerator();
            var content = ReadAllTextFromEmbeddedResource(filename + ".rl");
            var expected = ReadAllTextFromEmbeddedResource(filename + ".cs");

            // Act
            var actual = generator.Generate(filename, content, new DateTime(2016,1,1,8,0,0));

            // Assert
            Assert.AreEqual(FixWhitespaces(expected), FixWhitespaces(Encoding.UTF8.GetString(actual)));
        }
Ejemplo n.º 2
0
        public void GivenInvalidAndThenValidInput_Generate_ShouldReturnCSCodeWithErrorDirectiveAndThenProperCSCode(
            string invalid, string valid)
        {
            // Arrange
            var generator = new CodeGenerator();
            var invalidContent = ReadAllTextFromEmbeddedResource(invalid + ".rl");
            var invalidExpected = ReadAllTextFromEmbeddedResource(invalid + ".cs");
            var validContent = ReadAllTextFromEmbeddedResource(valid + ".rl");
            var validExpected = ReadAllTextFromEmbeddedResource(valid + ".cs");

            // Act
            var result1 = generator.Generate(invalid, invalidContent, new DateTime(2016, 1, 1, 8, 0, 0));
            var result2 = generator.Generate(valid, validContent, new DateTime(2016, 1, 1, 8, 0, 0));

            // Assert
            Assert.AreEqual(FixWhitespaces(invalidExpected), FixWhitespaces(Encoding.UTF8.GetString(result1)));
            Assert.AreEqual(FixWhitespaces(validExpected), FixWhitespaces(Encoding.UTF8.GetString(result2)));
        }