Moq.Mock.Verify()

Here are the examples of the csharp api Moq.Mock.Verify() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1587 Examples 7

19 View Source File : PropertyHandlerPrecedenceTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestPropertyHandlerPrecedenceOnQueryGroupExpression()
        {
            // Prepare
            var propertyHandler = new Mock<IPropertyHandler<int, int>>();
            FluentMapper
                .Enreplacedy<PropertyHandlerTestClreplacedForQueryGroup>()
                .PropertyHandler(e => e.Id, propertyHandler.Object);

            // Act
            using (var connection = new PropertyHandlerConnection())
            {
                connection.Query<PropertyHandlerTestClreplacedForQueryGroup>(new QueryGroup(new QueryField("Id", 1)));
            }

            // replacedert
            propertyHandler.Verify(c => c.Set(It.IsAny<int>(), It.IsAny<ClreplacedProperty>()), Times.Once);
        }

19 View Source File : PropertyHandlerPrecedenceTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestPropertyHandlerWithAttributePrecedenceOnQueryGroupExpression()
        {
            // Prepare
            var propertyHandler = new Mock<IPropertyHandler<int, int>>();
            FluentMapper
                .Enreplacedy<PropertyHandlerTestClreplacedWithAttributeForQueryGroup>()
                .PropertyHandler(e => e.Id, propertyHandler.Object);

            // Act
            using (var connection = new PropertyHandlerConnection())
            {
                connection.Query<PropertyHandlerTestClreplacedWithAttributeForQueryGroup>(new QueryGroup(new QueryField("Id", 1)));
            }

            // replacedert
            propertyHandler.Verify(c => c.Set(It.IsAny<int>(), It.IsAny<ClreplacedProperty>()), Times.Never);
        }

19 View Source File : FieldEqualityTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestFieldGetHashCodeInvocationOnCheckNotNull()
        {
            // Prepare
            var mockOfFiled = new Mock<Field>("FieldName");

            // Act
            if (mockOfFiled.Object != null){}
            
            // replacedert
            mockOfFiled.Verify(x => x.GetHashCode(), Times.Never);
        }

19 View Source File : OrderFieldEqualityTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestOrderFieldGetHashCodeInvocationOnCheckNotNull()
        {
            // Prepare
            var mockOfFiled = new Mock<OrderField>("OrderFieldName", Order.Ascending);

            // Act
            if (mockOfFiled.Object != null){}
            
            // replacedert
            mockOfFiled.Verify(x => x.GetHashCode(), Times.Never);
        }

19 View Source File : OrderFieldEqualityTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestOrderFieldGetHashCodeInvocationOnEqualsNotNull()
        {
            // Prepare
            var mockOfFiled = new Mock<OrderField>("OrderFieldName", Order.Ascending);
            var otherFiled = new OrderField("OrderFieldName", Order.Ascending);

            // Act
            mockOfFiled.Object.Equals(otherFiled);
            
            // replacedert
            mockOfFiled.Verify(x => x.GetHashCode(), Times.Once);
        }

19 View Source File : ICacheForBaseRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestBaseRepositoryQueryCachingViaQueryGroup()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new CacheEnreplacedyRepository(cache.Object, cacheItemExpiration);

            // Act
            repository.Query(where: (QueryGroup)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbConnectionTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbConnectionQueryCachingViaQueryField()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;

            // Act
            new CacheDbConnection().Query<CacheEnreplacedy>(where: (QueryField)null,
                fields: null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                cacheItemExpiration: cacheItemExpiration,
                commandTimeout: null,
                transaction: null,
                cache: cache.Object,
                trace: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbConnectionTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbConnectionQueryAsyncCachingViaQueryField()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;

            // Act
            var result = new CacheDbConnection().QueryAsync<CacheEnreplacedy>(where: (QueryField)null,
                fields: null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                cacheItemExpiration: cacheItemExpiration,
                commandTimeout: null,
                transaction: null,
                cache: cache.Object,
                trace: null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbConnectionTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbConnectionQueryAsyncCachingViaQueryFields()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;

            // Act
            var result = new CacheDbConnection().QueryAsync<CacheEnreplacedy>(where: (IEnumerable<QueryField>)null,
                fields: null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                cacheItemExpiration: cacheItemExpiration,
                commandTimeout: null,
                transaction: null,
                cache: cache.Object,
                trace: null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbConnectionTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbConnectionQueryAsyncCachingViaExpression()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;

            // Act
            var result = new CacheDbConnection().QueryAsync<CacheEnreplacedy>(where: (Expression<Func<CacheEnreplacedy, bool>>)null,
                fields: null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                cacheItemExpiration: cacheItemExpiration,
                commandTimeout: null,
                transaction: null,
                cache: cache.Object,
                trace: null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbConnectionTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbConnectionQueryAsyncCachingViaQueryGroup()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;

            // Act
            var result = new CacheDbConnection().QueryAsync<CacheEnreplacedy>(where: (QueryGroup)null,
                fields: null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                cacheItemExpiration: cacheItemExpiration,
                commandTimeout: null,
                transaction: null,
                cache: cache.Object,
                trace: null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingWithoutExpression()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>(where: (QueryGroup)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingViaDynamics()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>((object)null, /* whereOrPrimaryKey */
                (IEnumerable<OrderField>)null, /* orderBy */
                (int?)null, /* top */
                (string)null, /* hints */
                cacheKey, /* cacheKey */
                (IDbTransaction)null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingViaQueryField()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>(where: (QueryField)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingViaQueryFields()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>(where: (IEnumerable<QueryField>)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingViaExpression()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>(where: (Expression<Func<CacheEnreplacedy, bool>>)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryCachingViaQueryGroup()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            repository.Query<CacheEnreplacedy>(where: (QueryGroup)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null);

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryAsyncCachingWithoutExpression()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            var result = repository.QueryAsync<CacheEnreplacedy>(where: (QueryGroup)null,
                orderBy: null,
                top: 0,
                hints: null,
                cacheKey: cacheKey,
                transaction: null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ICacheForDbRepositoryTest.cs
License : Apache License 2.0
Project Creator : mikependon

[TestMethod]
        public void TestDbRepositoryQueryAsyncCachingViaDynamics()
        {
            // Prepare
            var cache = new Mock<ICache>();
            var cacheKey = "MemoryCacheKey";
            var cacheItemExpiration = 60;
            var repository = new DbRepository<CacheDbConnection>("ConnectionString",
                0,
                ConnectionPersistency.PerCall,
                cache.Object,
                cacheItemExpiration,
                null);

            // Act
            var result = repository.QueryAsync<CacheEnreplacedy>((object)null, /* whereOrPrimaryKey */
                (IEnumerable<OrderField>)null, /* orderBy */
                (int?)null, /* top */
                (string)null, /* hints */
                cacheKey, /* cacheKey */
                (IDbTransaction)null).Result;

            // replacedert
            cache.Verify(c => c.Get<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<bool>()), Times.Once);
            cache.Verify(c => c.Add<IEnumerable<CacheEnreplacedy>>(It.Is<string>(s => s == cacheKey),
                It.IsAny<IEnumerable<CacheEnreplacedy>>(),
                It.Is<int>(i => i == cacheItemExpiration),
                It.IsAny<bool>()), Times.Once);
        }

19 View Source File : ServerWrapperUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ConstructorTest()
    {
      const string _defaultConfigurationFileName = "DefaultFileName.tst";
      Mock<IConfiguration> _IConfigurationMock = new Mock<IConfiguration>();
      _IConfigurationMock.SetupGet<string>(x => x.DefaultFileName).Returns(_defaultConfigurationFileName);
      _IConfigurationMock.Setup(x => x.SaveConfiguration(It.IsAny<string>(), It.IsAny<FileInfo>()));
      Mock<IDataProviderDescription> _IDataProviderDescriptionMock = new Mock<IDataProviderDescription>();
      Mock<IGraphicalUserInterface> _guiMock = new Mock<IGraphicalUserInterface>();

      Mock<IFileDialog> _openFileDialogMock = new Mock<IFileDialog>();
      Mock<IFolderBrowserDialog> _IFolderBrowserDialog = new Mock<IFolderBrowserDialog>();
      List<string> _message = new List<string>();
      List<string> _caption = new List<string>();
      _guiMock.Setup(x => x.MessageBoxShowWarning);
      _guiMock.SetupGet(x => x.MessageBoxShowExclamation).Returns(() => (message, caption) => { _message.Add(message); _caption.Add(caption); });
      _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => () => _openFileDialogMock.Object);
      _guiMock.SetupGet(x => x.OpenFolderBrowserDialogFunc).Returns(() => () => _IFolderBrowserDialog.Object);
      _guiMock.SetupGet(x => x.MessageBoxShowError).Returns(() => (message, caption) => { _message.Add(message); _caption.Add(caption); });

      ServerWrapper _instanceUnderTest = new ServerWrapper(_IConfigurationMock.Object, _IDataProviderDescriptionMock.Object, _guiMock.Object);

      _IConfigurationMock.Verify(x => x.SaveConfiguration("", It.IsAny<FileInfo>()), Times.Once);
      _guiMock.VerifyGet(x => x.MessageBoxShowError, Times.Never);
      replacedert.AreEqual<int>(2, _message.Count);
      Collectionreplacedert.AreEqual(
        new string[] { "You did not choose the configuration file. Please select a location of the default configuration file.", "Folder is not selected, configuration will be created in the default location." },
        _message.ToArray());

      //Configuration
      replacedert.IsNotNull(_instanceUnderTest.Configuration);
      replacedert.IsNotNull(_instanceUnderTest.Configuration.ConfigurationFile);
      replacedert.AreEqual<string>(Path.Combine(Directory.GetCurrentDirectory(), _defaultConfigurationFileName), _instanceUnderTest.Configuration.ConfigurationFile.FullName);
      //PluginDescription
      replacedert.IsNotNull(_instanceUnderTest.PluginDescription);
      replacedert.AreSame(_IDataProviderDescriptionMock.Object, _instanceUnderTest.PluginDescription);
      IConfiguration _configurationEditor = _instanceUnderTest.GetServerConfiguration;
      replacedert.IsNotNull(_configurationEditor);
      replacedert.AreEqual(_IConfigurationMock.Object, _configurationEditor);
    }

19 View Source File : ConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ShowOpenDialogTestMethod()
    {
      const string DefaultExt = "uamdsl";
      const string FileName = "UAModelDesignerSolution";
      const string Filter = "UA Model Designer Solution File (* .uamdsl)|*.uamdsl|UA Model Designer Solution File (* .xml)|*.xml|All files(*.*)|*.*";
      const string replacedle = "UA Model Designer Solution Open/Save dialog window";
      string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents), FileName);
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupProperty(x => x.FileName);
      _IFileDialogMock.SetupGet<string>(x => x.FileName).Returns(_defPath);
      _IFileDialogMock.SetupProperty(x => x.DefaultExt);
      _IFileDialogMock.SetupProperty(x => x.Filter);
      _IFileDialogMock.SetupProperty(x => x.replacedle);
      _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(true);
      _IFileDialogMock.Setup(x => x.Dispose());
      Mock<IGraphicalUserInterface> _guiMock = new Mock<IGraphicalUserInterface>();
      _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
      string _retPath = ConfigurationManagementFixture.ShowOpenDialog(_guiMock.Object);
      _IFileDialogMock.VerifySet(x => x.DefaultExt = DefaultExt);
      _IFileDialogMock.VerifySet(x => x.FileName = It.IsAny<String>(), Times.Never);
      _IFileDialogMock.VerifyGet(x => x.FileName, Times.Once);
      _IFileDialogMock.VerifySet(x => x.Filter = Filter);
      _IFileDialogMock.VerifySet(x => x.replacedle = replacedle);
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Once);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Once);
      replacedert.AreEqual<string>(_defPath, _retPath);
    }

19 View Source File : ProjectConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void CreateNewTest()
    {
      Mock<ISolutionConfigurationManagement> _solutionMock = new Mock<ISolutionConfigurationManagement>();
      _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(@"C:\a\b\c\");
      _solutionMock.Setup(x => x.DefaultFileName);
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupGet(x => x.FileName).Throws<ApplicationException>();
      _IFileDialogMock.SetupGet(x => x.InitialDirectory).Throws<ApplicationException>();
      _IFileDialogMock.Setup(x => x.Dispose());
      _IFileDialogMock.Setup(x => x.ShowDialog());
      IProjectConfigurationManagement _newItem = ProjectConfigurationManagement.CreateNew(_solutionMock.Object, new GraphicalUserInterface(_IFileDialogMock.Object), "projectName");
      replacedert.IsTrue(((ProjectConfigurationManagement)_newItem).ChangesArePresent);
      replacedert.IsNotNull(_newItem.ModelDesign);
      replacedert.AreEqual<string>("projectName", _newItem.Name);
      replacedert.AreEqual<string>(@"C:\a\b\c", _newItem.DefaultDirectory);
      replacedert.AreEqual<string>(@"C:\a\b\c\projectName.xml", _newItem.DefaultFileName);
      CheckConsistency(_newItem.UAModelDesignerProject);
      //_solutionMock
      _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce);
      _solutionMock.Verify(x => x.DefaultFileName, Times.Never);
      //_IFileDialogMock
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.FileName, Times.Never);
      _IFileDialogMock.Verify(x => x.Filter, Times.Never);
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.replacedle, Times.Never);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
    }

19 View Source File : ProjectConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void SaveNewTest()
    {
      //TODO Creating new project the existing one should not be overridden #174
      string _solutionPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData");
      Mock<ISolutionConfigurationManagement> _solutionMock = new Mock<ISolutionConfigurationManagement>();
      _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(_solutionPath);
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      Mock<IGraphicalUserInterface> _guiMock = new Mock<IGraphicalUserInterface>();
      _guiMock.SetupGet(z => z.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
      _guiMock.SetupSet(z => z.UseWaitCursor = It.IsAny<bool>());
      IProjectConfigurationManagement _newItem = ProjectConfigurationManagement.CreateNew(_solutionMock.Object, _guiMock.Object, "projectName");
      replacedert.IsTrue(((ProjectConfigurationManagement)_newItem).ChangesArePresent);
      replacedert.IsNotNull(_newItem.ModelDesign);
      replacedert.AreEqual<string>("projectName", _newItem.Name);
      replacedert.IsNotNull(_newItem.UAModelDesignerProject);
      _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce);
      _solutionMock.Verify(x => x.DefaultFileName, Times.Never);
      ModelDesign _modelDesign = new ModelDesign
      {
        Namespaces = new Namespace[] { new Namespace() { Name = "Namespace" } }
      };
      //test save
      _newItem.Save(_modelDesign);
      _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce);
      _solutionMock.Verify(x => x.DefaultFileName, Times.Never);
      _guiMock.VerifySet(x => x.UseWaitCursor = true, Times.Once);
      _guiMock.VerifySet(x => x.UseWaitCursor = false, Times.Once);
      replacedert.IsTrue(File.Exists(Path.Combine(_solutionPath, "projectName.xml")));
      //_IFileDialogMock
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.FileName, Times.Never);
      _IFileDialogMock.Verify(x => x.Filter, Times.Never);
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.replacedle, Times.Never);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
    }

19 View Source File : ConfigurationWrapperUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void SaveTest()
    {
      FileInfo _fileInforFixture = new FileInfo(ConfigurationPath);
      Mock<IConfiguration> _iConfigurationMock = new Mock<IConfiguration>();
      _iConfigurationMock.Setup(x => x.SaveConfiguration(It.IsAny<string>(), _fileInforFixture));
      Mock<IGraphicalUserInterface> _iGraphicalUserInterface = new Mock<IGraphicalUserInterface>();
      ConfigurationWrapper _underTesreplacedem = new ConfigurationWrapper(_fileInforFixture, _iConfigurationMock.Object, _iGraphicalUserInterface.Object);
      replacedert.AreEqual<string>(ConfigurationPath, _underTesreplacedem.ConfigurationFile.FullName);
      _underTesreplacedem.Save("wrong_path");
      _iConfigurationMock.Verify(x => x.SaveConfiguration("wrong_path", _fileInforFixture), Times.Once);
      replacedert.AreEqual<string>(ConfigurationPath, _underTesreplacedem.ConfigurationFile.FullName);
    }

19 View Source File : ConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void DefaultFileNameTest()
    {
      string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents), "UAModelDesignerSolution");
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupProperty(x => x.FileName);
      ConfigurationManagementFixture _newItem = new ConfigurationManagementFixture(_IFileDialogMock.Object, _defPath);
      int OnModificationCounter = 0;
      _newItem.DefaultFileNameHasChanged += (x, y) => OnModificationCounter++;
      _newItem.SetFilePath(@"c:\\folder\file.name");
      replacedert.AreEqual<int>(1, OnModificationCounter);
      replacedert.IsFalse(String.IsNullOrEmpty(_newItem.DefaultDirectory));
      replacedert.IsFalse(_newItem.ChangesArePresent);
      _IFileDialogMock.Verify(x => x.FileName, Times.Never);
      _IFileDialogMock.VerifySet(x => x.FileName = It.IsAny<string>(), Times.Never);
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
    }

19 View Source File : SolutionConfigurationManagementtUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void OpenExistingSkippedTest()
    {
      const string DefaultExt = "uamdsl";
      const string Filter = "UA Model Designer Solution File (* .uamdsl)|*.uamdsl|UA Model Designer Solution File (* .xml)|*.xml|All files(*.*)|*.*";
      const string replacedle = "UA Model Designer Solution Open/Save dialog window";
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupProperty(x => x.DefaultExt);
      _IFileDialogMock.SetupProperty(x => x.Filter);
      _IFileDialogMock.SetupProperty(x => x.replacedle);
      _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(false);
      Mock<IGraphicalUserInterface> _guiMock = new Mock<IGraphicalUserInterface>();
      _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
      _guiMock.SetupGet(x => x.MessageBoxShowWarningAskYN).Returns(() => (x, y) => true);
      ISolutionConfigurationManagement _instance = null;
      SolutionConfigurationManagementRoot _freshInstance = null;
      SolutionConfigurationManagementRoot.GetInstance(c => _freshInstance = c);
      _freshInstance.AfterSolutionChange += (x, y) => _instance = y.Solution;
      SolutionConfigurationManagementRoot.OpenExisting(null, _guiMock.Object);
      _IFileDialogMock.VerifySet(x => x.DefaultExt = DefaultExt, Times.Never);
      _IFileDialogMock.VerifySet(x => x.Filter = Filter, Times.Never);
      _IFileDialogMock.VerifySet(x => x.replacedle = replacedle, Times.Never);
      _IFileDialogMock.VerifySet(x => x.FileName = It.IsAny<string>(), Times.Never);
      _IFileDialogMock.VerifySet(x => x.InitialDirectory = It.IsAny<string>(), Times.Never);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
    }

19 View Source File : SolutionConfigurationManagementtUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void OpenExistingFileExistTest()
    {
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(false);
      Mock<IGraphicalUserInterface> _guiMock = new Mock<IGraphicalUserInterface>();
      _guiMock.SetupSet(x => x.UseWaitCursor = It.IsAny<bool>());
      _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
      _guiMock.SetupGet(x => x.MessageBoxShowWarningAskYN).Returns(() => (x, y) => true);
      ISolutionConfigurationManagement _instance = null;
      SolutionConfigurationManagementRoot _freshInstance = null;
      SolutionConfigurationManagementRoot.GetInstance(c => _freshInstance = c);
      _freshInstance.AfterSolutionChange += (x, y) => _instance = y.Solution;
      SolutionConfigurationManagementRoot.OpenExisting(@"TestData\EmptySolution.uamdsl", _guiMock.Object);
      replacedert.IsNotNull(_instance);
      replacedert.IsFalse(_instance.ChangesArePresent);
      replacedert.AreEqual<string>(Path.Combine(Directory.GetCurrentDirectory(), @"TestData\EmptySolution.uamdsl"), _instance.DefaultFileName);
      _IFileDialogMock.Verify(x => x.DefaultExt, Times.Never);
      _IFileDialogMock.Verify(x => x.Filter, Times.Never);
      _IFileDialogMock.Verify(x => x.replacedle, Times.Never);
      _IFileDialogMock.Verify(x => x.FileName, Times.Never);
      _IFileDialogMock.VerifySet(x => x.InitialDirectory = It.IsAny<string>(), Times.Never);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
      _guiMock.Verify(x => x.MessageBoxShowWarningAskYN, Times.Never);
      _guiMock.VerifySet(x => x.UseWaitCursor = It.IsAny<bool>(), Times.Exactly(2));
    }

19 View Source File : BaseModelUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void GetTargetNamespaceTest()
    {
      BaseTreeNodeFixture instance2Test = new BaseTreeNodeFixture(RandomTekst);
      Mock<IBaseModel> mock = new Mock<IBaseModel>();
      instance2Test.Parent = mock.Object;
      _ = instance2Test.GetTargetNamespace();
      instance2Test.CreateInstanceConfigurations(null, false, out bool cancel);
      _ = instance2Test.AvailiableNamespaces;

      mock.Verify(x => x.GetTargetNamespace(), Times.Once);
      mock.Verify(x => x.CreateInstanceConfigurations(null, false, out cancel), Times.Once);
      mock.VerifyGet(x => x.AvailiableNamespaces, Times.Once);
    }

19 View Source File : ProjectTreeNodeUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void BuildTest()
    {
      Mock<IProjectConfigurationManagement> _projectConfigurationMock = new Mock<IProjectConfigurationManagement>();
      Mock<OPCFModelDesign> _OPCFModelDesignMock = new Mock<OPCFModelDesign>();
      _projectConfigurationMock.SetupGet<OPCFModelDesign>(x => x.ModelDesign).Returns(_OPCFModelDesignMock.Object);
      _projectConfigurationMock.SetupGet<string>(x => x.Name).Returns("EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327");

      //_projectConfigurationMock.Setup(x => x.Build( z => { } ));
      Mock<BaseModel> _parentMock = new Mock<BaseModel>("ParentBaseNode");

      ProjectTreeNode _newItem = new ProjectTreeNode(_projectConfigurationMock.Object) { Parent = _parentMock.Object };
      List<string> trace = new List<string>();
      Action<string> tracer = x => trace.Add(x);
      _newItem.Build(tracer);
      _projectConfigurationMock.Verify(x => x.Build(tracer), Times.Once);
      replacedert.AreEqual<int>(4, trace.Count);
      replacedert.AreEqual<string>("------ Building project: EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327. ------", trace[0]);
      replacedert.IsTrue(trace[1].StartsWith("Build started at:"));
      replacedert.IsTrue(trace[2].StartsWith("Build ended at:"));
      replacedert.AreEqual<string>("", trace[3]);
      foreach (string msg in trace)
        System.Diagnostics.Debug.WriteLine(msg);
    }

19 View Source File : ConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ConstructorTest()
    {
      string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents), "UAModelDesignerSolution.uax");
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupProperty<string>(x => x.FileName);
      ConfigurationManagementFixture _newItem = new ConfigurationManagementFixture(_IFileDialogMock.Object, _defPath);
      replacedert.IsFalse(_newItem.ChangesArePresent);
      replacedert.IsFalse(String.IsNullOrEmpty(_newItem.DefaultDirectory));
      replacedert.AreEqual<string>("UAModelDesignerSolution.uax", Path.GetFileName(_newItem.DefaultFileName));
      replacedert.IsFalse(String.IsNullOrEmpty(Path.GetPathRoot(_newItem.DefaultFileName)));
      _IFileDialogMock.Verify(x => x.FileName, Times.Never);
      _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never);
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
    }

19 View Source File : ConfigurationManagementUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ShowDialogSaveFileDialogTest()
    {
      const string DefaultExt = "uamdsl";
      const string Filter = "UA Model Designer Solution File (* .uamdsl)|*.uamdsl|UA Model Designer Solution File (* .xml)|*.xml|All files(*.*)|*.*";
      const string replacedle = "UA Model Designer Solution Open/Save dialog window";
      string _defPath = @"c:\a\b\c\d.e";
      string _altPath = @"c:\a\b\f\d.e";
      Mock<IFileDialog> _IFileDialogMock = new Mock<IFileDialog>();
      _IFileDialogMock.SetupProperty(x => x.FileName);
      _IFileDialogMock.SetupProperty(x => x.DefaultExt);
      _IFileDialogMock.SetupProperty(x => x.Filter);
      _IFileDialogMock.SetupProperty(x => x.replacedle);
      _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(true);
      _IFileDialogMock.Setup(x => x.Dispose());
      _IFileDialogMock.SetupGet<string>(x => x.FileName).Returns(_altPath);
      ConfigurationManagementFixture _item = new ConfigurationManagementFixture(_IFileDialogMock.Object, _defPath);
      replacedert.AreEqual<string>(_defPath, _item.DefaultFileName);
      int _eventCounter = 0;
      string NewDirectoryPath = String.Empty;
      string OldDirectoryPath = String.Empty;
      _item.DefaultFileNameHasChanged += (object sender, NewDirectoryPathEventArgs e) =>
        {
          _eventCounter++;
          replacedert.AreSame(_item, sender);
          NewDirectoryPath = e.NewDirectoryPath;
          OldDirectoryPath = e.OldDirectoryPath;
        };
      replacedert.AreEqual<string>(_defPath, _item.DefaultFileName);
      _item.SaveFixture();
      replacedert.AreEqual<string>(_altPath, _item.DefaultFileName);
      replacedert.AreEqual<int>(1, _eventCounter);
      replacedert.AreEqual<string>(@"c:\a\b\f", NewDirectoryPath);
      replacedert.AreEqual<string>(@"c:\a\b\c", OldDirectoryPath);
      _IFileDialogMock.VerifySet(x => x.DefaultExt = DefaultExt);
      _IFileDialogMock.VerifySet(x => x.Filter = Filter);
      _IFileDialogMock.VerifySet(x => x.replacedle = replacedle);
      _IFileDialogMock.VerifySet(x => x.FileName = Path.GetFileNameWithoutExtension(_defPath));
      _IFileDialogMock.VerifySet(x => x.InitialDirectory = Path.GetDirectoryName(_defPath));
      _IFileDialogMock.Verify(x => x.Dispose(), Times.Once);
      _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Once);
    }

19 View Source File : XmlQualifiedNameEditorWithDefaultValueUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ConstructorTest1()
    {
      Mock<IXmlQualifiedNameEditorNamespaceProvider> mock = new Mock<IXmlQualifiedNameEditorNamespaceProvider>();
      XmlQualifiedNameEditorWithDefaultValue toTest = new XmlQualifiedNameEditorWithDefaultValue(new XmlQualifiedName("name", "namespace"), mock.Object, new XmlQualifiedName("defaultName", "defaultNamespace"));
      replacedert.IsNotNull(toTest.DefaultValue);
      replacedert.IsFalse(toTest.IsEmpty);
      replacedert.IsFalse(toTest.IsNull);
      replacedert.AreEqual<string>("name", toTest.Name);
      replacedert.IsFalse(toTest.NameIsBasedOnDefault);
      replacedert.AreEqual<string>("namespace", toTest.NameSpace);
      XmlQualifiedName qNmame = toTest.XmlQualifiedName;
      replacedert.IsNotNull(qNmame);
      replacedert.AreEqual<string>("name", qNmame.Name);
      replacedert.AreEqual<string>("namespace", qNmame.Namespace);
      qNmame = toTest.ValueOrDefault;
      replacedert.IsNotNull(qNmame);
      replacedert.AreEqual<string>("name", qNmame.Name);
      replacedert.AreEqual<string>("namespace", qNmame.Namespace);
      mock.Verify(x => x.GetAvailiableNamespaces(), Times.Never);
      mock.Verify(x => x.GetTargetNamespace(), Times.Never);
    }

19 View Source File : XmlQualifiedNameEditorWithDefaultValueUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void ConstructorTest2()
    {
      Mock<IXmlQualifiedNameEditorNamespaceProvider> mock = new Mock<IXmlQualifiedNameEditorNamespaceProvider>();
      XmlQualifiedNameEditorWithDefaultValue toTest = new XmlQualifiedNameEditorWithDefaultValue(null, mock.Object, new XmlQualifiedName("defaultName", "defaultNamespace"));
      replacedert.IsNotNull(toTest.DefaultValue);
      replacedert.IsTrue(toTest.IsEmpty);
      replacedert.IsTrue(toTest.IsNull);
      replacedert.AreEqual<string>("", toTest.Name);
      replacedert.IsFalse(toTest.NameIsBasedOnDefault);
      replacedert.AreEqual<string>("", toTest.NameSpace);
      replacedert.IsNull(toTest.XmlQualifiedName);
      XmlQualifiedName qNmame = toTest.ValueOrDefault;
      replacedert.IsNotNull(qNmame);
      replacedert.AreEqual<string>("defaultName", qNmame.Name);
      replacedert.AreEqual<string>("defaultNamespace", qNmame.Namespace);
      mock.Verify(x => x.GetAvailiableNamespaces(), Times.Never);
      mock.Verify(x => x.GetTargetNamespace(), Times.Never);
    }

19 View Source File : XmlQualifiedNameEditorWithDefaultValueUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void XmlQualifiedNameHasChangedTest()
    {
      Mock<IXmlQualifiedNameEditorNamespaceProvider> mock = new Mock<IXmlQualifiedNameEditorNamespaceProvider>();
      XmlQualifiedNameEditorWithDefaultValue toTest = new XmlQualifiedNameEditorWithDefaultValue(new XmlQualifiedName("name", "namespace"), mock.Object, new XmlQualifiedName("defaultName", "defaultNamespace"));
      int callCounter = 0;
      toTest.XmlQualifiedNameHasChanged += (src, ea) => callCounter++;
      toTest.Name = "NewName";
      replacedert.AreEqual<string>("NewName", toTest.Name);
      replacedert.AreEqual<string>("namespace", toTest.NameSpace);
      replacedert.AreEqual<int>(1, callCounter);
      mock.Verify(x => x.GetAvailiableNamespaces(), Times.Never);
      mock.Verify(x => x.GetTargetNamespace(), Times.Never);
    }

19 View Source File : ConfigurationWrapperUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void GetPluginMenuItemsTest()
    {
      FileInfo _fileInforFixture = new FileInfo(ConfigurationPath);
      Mock<IConfiguration> _iConfigurationMock = new Mock<IConfiguration>();
      _iConfigurationMock.Setup(x => x.SaveConfiguration(It.IsAny<string>(), _fileInforFixture));
      Mock<IGraphicalUserInterface> _iGraphicalUserInterface = new Mock<IGraphicalUserInterface>();
      ConfigurationWrapper _underTesreplacedem = new ConfigurationWrapper(_fileInforFixture, _iConfigurationMock.Object, _iGraphicalUserInterface.Object);
      List<ToolStripItem> _menuItems = new List<ToolStripItem>();
      _underTesreplacedem.GetPluginMenuItems(_menuItems);
      replacedert.AreEqual<int>(1, _menuItems.Count);
      replacedert.AreEqual<int>(5, ((ToolStripMenuItem)_menuItems[0]).DropDownItems.Count);
      replacedert.AreEqual<string>("Save", ((ToolStripMenuItem)_menuItems[0]).DropDownItems[2].Text);
      ((ToolStripMenuItem)_menuItems[0]).DropDownItems[2].PerformClick();
      _underTesreplacedem.SetHomeDirectory(@"C:\x\y\z");
      ((ToolStripMenuItem)_menuItems[0]).DropDownItems[2].PerformClick();
      _iConfigurationMock.Verify(x => x.SaveConfiguration(null, _fileInforFixture), Times.Once);
      _iConfigurationMock.Verify(x => x.SaveConfiguration(@"C:\x\y\z", _fileInforFixture), Times.Once);
    }

19 View Source File : ServerSelectorUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void GetPluginRelativePathNamesXTest()
    {
      Mock<ISolutionDirectoryPathManagement> _directory = new Mock<ISolutionDirectoryPathManagement>();
      _directory.SetupGet(x => x.DefaultDirectory).Returns(Directory.GetCurrentDirectory());
      Mock<IGraphicalUserInterface> _gui = new Mock<IGraphicalUserInterface>();
      Mock<IFileDialog> _openFileDialogMock = new Mock<IFileDialog>();
      Mock<IFolderBrowserDialog> _IFolderBrowserDialog = new Mock<IFolderBrowserDialog>();
      string _message = String.Empty;
      string _caption = String.Empty;
      _gui.Setup(x => x.MessageBoxShowWarning);
      _gui.Setup(x => x.MessageBoxShowError);
      _gui.SetupGet(x => x.MessageBoxShowExclamation).Returns(() => (message, caption) => { _message = message; _caption = caption; });
      _gui.SetupGet(x => x.OpenFileDialogFunc).Returns(() => () => _openFileDialogMock.Object);
      _gui.SetupGet(x => x.OpenFolderBrowserDialogFunc).Returns(() => () => _IFolderBrowserDialog.Object);
      ServerSelector _underTesreplacedem = new ServerSelector(_gui.Object, _directory.Object, m_PluginFullPath, "");
      ServerSelector.ServerDescriptor _pluginPaths = _underTesreplacedem.ServerConfiguration;
      //test behavior
      _gui.Verify(x => x.MessageBoxShowError, Times.Never);
      _gui.Verify(x => x.MessageBoxShowWarning, Times.Never);
      _gui.Verify(x => x.MessageBoxShowExclamation, Times.Exactly(2));
      _gui.Verify(x => x.OpenFileDialogFunc, Times.Once);
      _gui.Verify(x => x.OpenFolderBrowserDialogFunc, Times.Once);
      //test result
      replacedert.IsNotNull(_pluginPaths);
      replacedert.AreEqual<string>(m_ConfigurationDefaultFileName, _pluginPaths.Configuration);
      replacedert.AreEqual<string>(m_PluginFullPath, _pluginPaths.Codebase);
    }

19 View Source File : ProjectTreeNodeUnitTest.cs
License : MIT License
Project Creator : mpostol

[TestMethod]
    public void SaveTest()
    {
      //preparation
      Mock<IProjectConfigurationManagement> _projectConfigurationMock = new Mock<IProjectConfigurationManagement>();
      Mock<OPCFModelDesign> _OPCFModelDesignMock = new Mock<OPCFModelDesign>();
      _projectConfigurationMock.SetupGet<OPCFModelDesign>(x => x.ModelDesign).Returns(_OPCFModelDesignMock.Object);
      _projectConfigurationMock.SetupGet<string>(x => x.Name).Returns("EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327");
      Mock<BaseModel> _parentMock = new Mock<BaseModel>("ParentBaseNode");
      _parentMock.SetupGet<string[]>(x => x.AvailiableNamespaces).Returns(new List<string>() { "ns1", "ns2" }.ToArray());
      _parentMock.Setup(x => x.GetTargetNamespace()).Returns("GetTargetNamespace");
      //create object under test
      ProjectTreeNode _newItem = new ProjectTreeNode(_projectConfigurationMock.Object) { Parent = _parentMock.Object };

      _newItem.Save();

      _projectConfigurationMock.Verify(x => x.Save(It.IsAny<OPCFModelDesign>()), Times.Once);
    }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Theory]
        [InlineData(0)]
        [InlineData("")]
        public void Start_Valid_CreateUiCalled(object jobId)
        {
            var uiMock = SetupUI();

            uiMock.Object.Start(null, jobId, Testreplacedle);

            uiMock.Verify(x => x.CreateUI(null, Testreplacedle, It.IsAny<bool>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Stop_Valid_StopCalledOnWindow()
        {
            var uiMock = SetupUI();

            uiMock.Object.Start(null, TestJobId, Testreplacedle);
            uiMock.Object.Close(TestJobId);

            replacedert.Single(uiMock.Object.Instances);
            var wMock = Mock.Get<IUserInterfaceWindow>(uiMock.Object.Instances[0]);
            wMock.Verify(x => x.Close(), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Display_ProcessManagerWithJobId_DisplayTaskCalledOnWindow()
        {
            var uiMock = SetupUI();
            var manager = SetupManager();
            manager.Options.JobId = TestJobId;

            uiMock.Object.Start(null, TestJobId, Testreplacedle);
            uiMock.Object.Display(null, manager);

            var wMock = Mock.Get<IUserInterfaceWindow>(uiMock.Object.Instances[0]);
            wMock.Verify(x => x.DisplayTask(It.IsAny<IProcessWorker>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Display_ProcessManagerWithreplacedle_CreateUiCalled()
        {
            var uiMock = SetupUI();
            var manager = SetupManager();
            manager.Options.replacedle = Testreplacedle;

            uiMock.Object.Display(null, manager);

            uiMock.Verify(x => x.CreateUI(null, Testreplacedle, It.IsAny<bool>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Theory]
        [InlineData(0)]
        [InlineData("")]
        public void Start_Valid_CreateUiCalled(object jobId) {
            var UiMock = SetupUI();

            UiMock.Object.Start(jobId, Testreplacedle);

            UiMock.Verify(x => x.CreateUI(Testreplacedle, It.IsAny<bool>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Stop_Valid_StopCalledOnWindow() {
            var UiMock = SetupUI();

            UiMock.Object.Start(TestJobId, Testreplacedle);
            UiMock.Object.Stop(TestJobId);

            replacedert.Single(UiMock.Object.Instances);
            var WMock = Mock.Get<IUserInterfaceWindow>(UiMock.Object.Instances[0]);
            WMock.Verify(x => x.Stop(), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Display_ProcessManagerWithJobId_DisplayTaskCalledOnWindow() {
            var UiMock = SetupUI();
            var Manager = SetupManager();
            Manager.Options.JobId = TestJobId;

            UiMock.Object.Start(TestJobId, Testreplacedle);
            UiMock.Object.Display(Manager);

            var WMock = Mock.Get<IUserInterfaceWindow>(UiMock.Object.Instances[0]);
            WMock.Verify(x => x.DisplayTask(It.IsAny<IProcessManager>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void Display_ProcessManagerWithreplacedle_CreateUiCalled() {
            var UiMock = SetupUI();
            var Manager = SetupManager();
            Manager.Options.replacedle = Testreplacedle;

            UiMock.Object.Display(Manager);

            UiMock.Verify(x => x.CreateUI(Testreplacedle, It.IsAny<bool>()), Times.Once);
        }

19 View Source File : UserInterfaceManagerBaseTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Fact]
        public void RunWithOptionDisplayErrorOnly_Timeout_DisplayError() {
            var UiMock = SetupUI();
            var Manager = SetupManager();
            config.Setup(x => x.UserInterfaceManager).Returns(UiMock.Object);
            Manager.Options.DisplayMode = FFmpegDisplayMode.ErrorOnly;
            Manager.Options.Timeout = TimeSpan.FromMilliseconds(10);
            Manager.ProcessStarted += (s, e) => {
                var PMock = Mock.Get<IProcess>(e.ProcessManager.WorkProcess);
                PMock.Setup(x => x.WaitForExit(It.IsAny<int>())).Returns(false);
            };

            Manager.Run(TestFileName, null);

            UiMock.Verify(x => x.DisplayError(Manager), Times.Once);
        }

19 View Source File : FFmpegConfigTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Theory]
        [InlineData(true)]
        [InlineData(false)]
        public void SoftKill_Valid_AttachedConsoleCalled(bool handled)
        {
            var config = SetupConfig();
            CloseProcessEventArgs calledArgs = null;
            config.CloseProcess += (s, e) =>
            {
                calledArgs = e;
                if (handled)
                {
                    e.Handled = true;
                }
            };
            var process = Mock.Of<IProcess>(x => x.HasExited == true && x.Id == 1);

            var result = config.SoftKill(process);

            replacedert.True(result);
            replacedert.NotNull(calledArgs);
            replacedert.Equal(process, calledArgs.Process);
            // Very AttachConsole was called. The rest of SoftKillWinApp will not be tested.
            _api.Verify(x => x.AttachConsole((uint)process.Id), handled ? Times.Never() : Times.Once());
        }

19 View Source File : FFmpegConfigTests.cs
License : BSD 2-Clause "Simplified" License
Project Creator : mysteryx93

[Theory]
        [InlineData(true)]
        [InlineData(false)]
        public void SoftKill_Valid_AttachedConsoleCalled(bool handled) {
            var Config = SetupConfig();
            CloseProcessEventArgs CalledArgs = null;
            Config.CloseProcess += (s, e) => {
                CalledArgs = e;
                if (handled)
                    e.Handled = true;
            };
            var Process = Mock.Of<IProcess>(x => x.HasExited == true && x.Id == 1);

            bool Result = Config.SoftKill(Process);

            replacedert.True(Result);
            replacedert.NotNull(CalledArgs);
            replacedert.Equal(Process, CalledArgs.Process);
            // Very AttachConsole was called. The rest of SoftKillWinApp will not be tested.
            api.Verify(x => x.AttachConsole((uint)Process.Id), handled ? Times.Never() : Times.Once());
        }

19 View Source File : CellsValueValidatorTests.cs
License : MIT License
Project Creator : navferty

[TestMethod]
		public void Validate_Success_And_Fail()
		{
			var cells = new[]
			{
				new RangeBuilder().WithSingleValue(true).Build(),
				new RangeBuilder().WithSingleValue(true).Build(),
				new RangeBuilder().WithSingleValue(false).Build(),
				new RangeBuilder().WithSingleValue("").Build()
			};
			var selection = new RangeBuilder().WithEnumrableRanges(cells).WithWorksheet().Build();

			validator
				.Setup(x => x.CheckValue(It.IsAny<object>()))
				.Returns((bool x) => x ? ValidationResult.Success : ValidationResult.Fail("Fail =("));

			var result = cellsValidator.Validate(selection, ValidationType.Xml);

			replacedert.AreEqual(1, result.Count);
			validator.Verify(x => x.CheckValue(It.IsAny<object>()), Times.Exactly(3));
		}

19 View Source File : ConditionalFormatFixerTests.cs
License : MIT License
Project Creator : navferty

private static void VerifyPasted(Mock<Microsoft.Office.Interop.Excel.Range> range)
		{
			range.Verify(x => x.PasteSpecial(
				XlPasteType.xlPasteFormats,
				It.IsAny<XlPasteSpecialOperation>(),
				Missing.Value,
				Missing.Value), Times.Once);
		}

See More Examples