コード例 #1
0
        public void Should_Be_Able_To_Get_Databases()
        {
            // Arrange
            var sut = ResolveTestSubjectInstance();
            // Act

            var fakeMetadataProvider = new FakeContactMetadataProvider();
            var typeProvider         = new DynamicsAttributeTypeProvider();

            var fakeConn = MockRepository.GenerateMock <CrmDbConnection>();

            fakeConn.Stub(a => a.ConnectionInfo).Return(new CrmConnectionInfo()
            {
                OrganisationId = Guid.NewGuid(), OrganisationName = "unittest", ServerVersion = "1.0.0.0"
            });
            fakeConn.Stub(a => a.MetadataProvider).Return(fakeMetadataProvider);
            fakeConn.Stub(a => a.ServerVersion).Return("1.0.0.0");

            var collection = sut.GetDatabases(fakeConn, null);

            // Assert
            Assert.That(collection, Is.Not.Null);
            Assert.That(collection.Columns, Is.Not.Null);
            Assert.That(collection.Columns.Count, Is.AtLeast(3));
            Assert.That(collection.Rows.Count, Is.AtLeast(1));
            var value = collection.Rows[0][0];

            Assert.That((string)value == "unittest");
        }
コード例 #2
0
        public ConnectionTestsSandbox()
            : base()
        {
            // Arrange by registering our fake services into the test container.
            FakeOrgService = this.RegisterMockInstance<IOrganizationService, IDisposable>();
            FakeServiceProvider = this.RegisterMockInstance<ICrmServiceProvider>();
            FakeServiceProvider.Stub(c => c.GetOrganisationService()).Return(FakeOrgService);

            FakeConnectionProvider = this.RegisterMockInstance<ICrmConnectionProvider>();
            FakeConnectionProvider.Stub(c => c.OrganisationServiceConnectionString).Return("fakeconn=true");
            FakeServiceProvider.Stub(c => c.ConnectionProvider).Return(FakeConnectionProvider);

            FakeMetadataProvider = new FakeContactMetadataProvider();
            this.Container.Register<ICrmMetaDataProvider>(FakeMetadataProvider);
        }
コード例 #3
0
        public ConnectionTestsSandbox()
            : base()
        {
            // Arrange by registering our fake services into the test container.
            FakeOrgService      = this.RegisterMockInstance <IOrganizationService, IDisposable>();
            FakeServiceProvider = this.RegisterMockInstance <ICrmServiceProvider>();
            FakeServiceProvider.Stub(c => c.GetOrganisationService()).Return(FakeOrgService);

            FakeConnectionProvider = this.RegisterMockInstance <ICrmConnectionProvider>();
            FakeConnectionProvider.Stub(c => c.OrganisationServiceConnectionString).Return("fakeconn=true");
            FakeServiceProvider.Stub(c => c.ConnectionProvider).Return(FakeConnectionProvider);

            FakeMetadataProvider = new FakeContactMetadataProvider();
            this.Container.Register <ICrmMetaDataProvider>(FakeMetadataProvider);
        }
コード例 #4
0
        public void Should_Be_Able_To_Get_DataSourceInfo()
        {
            // Arrange
            var sut = ResolveTestSubjectInstance();
            // Act

            var fakeMetadataProvider = new FakeContactMetadataProvider();
            var typeProvider         = new DynamicsAttributeTypeProvider();

            var fakeConn = MockRepository.GenerateMock <CrmDbConnection>();

            fakeConn.Stub(a => a.MetadataProvider).Return(fakeMetadataProvider);
            fakeConn.Stub(a => a.ServerVersion).Return("1.0.0.0");

            var collection = sut.GetDataSourceInfo(fakeConn);

            // Assert
            Assert.That(collection, Is.Not.Null);
            Assert.That(collection.Columns, Is.Not.Null);
            Assert.That(collection.Columns.Count, Is.AtLeast(17));
        }