Пример #1
0
        public void TestTryFindFileUri()
        {
            //Arrange
            //The dyn file passed as parameter doesn't exists, so a different part in TryFindFile method will be executed
            string wspath = Path.Combine(TestDirectory, @"core\callsite\RebindingSingleDimension1.dyn");

            var fileCommand = new DynamoModel.OpenFileCommand(wspath);

            CustomXmlDocument xmlDocument = new CustomXmlDocument();

            //We set the URI to be fake so when it's split on TryFindFile it will execute a different code section
            xmlDocument.CustomBaseURL = "http://localhost/test";
            XmlElement elemTest = xmlDocument.CreateElement("TestCommand");

            //Act
            var command = new OpenFileCommandDerivedTest(wspath);

            command.SerializeCoreTest(elemTest);

            //Assert
            Assert.Throws <FileNotFoundException>(() => OpenFileCommand.DeserializeCore(elemTest));
        }
Пример #2
0
        public void TestTryFindFile()
        {
            //Arrange
            string wspath      = Path.Combine(TestDirectory, @"core\callsite\RebindingSingleDimension.dyn");
            var    fileCommand = new DynamoModel.OpenFileCommand(wspath);

            //We need a XmlDocument instance to create a new custom XmlElement
            XmlDocument xmlDocument = new XmlDocument();
            XmlElement  elemTest    = xmlDocument.CreateElement("TestCommand");

            //Act
            var command = new OpenFileCommandDerivedTest(wspath);

            command.SerializeCoreTest(elemTest);
            var deserializedCommand = OpenFileCommand.DeserializeCore(elemTest);

            //We need to set up the DynamoModel inside the OpenFileCommandDerivedTest class before calling TrackAnalytics()
            command.ExecuteTest(CurrentDynamoModel);
            command.TrackAnalytics();

            //Assert
            //It will validate that the Deserialized element is valid
            Assert.IsNotNull(deserializedCommand);
        }