コード例 #1
0
        public async Task GetDefaultConstraintsAsync_CorrectCreation_MoreConstraints_Async()
        {
            // Arrange
            var        xfsMock        = Mock.Of <IXmlFormatService>();
            var        tempDacpacPath = WriteEmbeddedResourceToTemporaryFile("TestDatabase_AuthorWithDefaultConstraints.dacpac");
            IDacAccess da             = new DacAccess(xfsMock);

            // Act
            var(defaultConstraints, errors) = await da.GetDefaultConstraintsAsync(tempDacpacPath);

            // Assert
            Assert.IsNotNull(defaultConstraints);
            Assert.IsNull(errors);
            Assert.AreEqual(3, defaultConstraints.Length);
            var orderedConstraints = defaultConstraints.OrderBy(m => m.ColumnName)
                                     .ToArray();

            // First constraint
            Assert.AreEqual("dbo", orderedConstraints[0].TableSchema);
            Assert.AreEqual("Author", orderedConstraints[0].TableName);
            Assert.AreEqual("Birthday", orderedConstraints[0].ColumnName);
            Assert.AreEqual("DF_Birthday_Today", orderedConstraints[0].ConstraintName);
            // Second constraint
            Assert.AreEqual("dbo", orderedConstraints[1].TableSchema);
            Assert.AreEqual("Author", orderedConstraints[1].TableName);
            Assert.AreEqual("FirstName", orderedConstraints[1].ColumnName);
            Assert.AreEqual("DF_FirstName_Empty", orderedConstraints[1].ConstraintName);
            // Third constraint
            Assert.AreEqual("dbo", orderedConstraints[2].TableSchema);
            Assert.AreEqual("Author", orderedConstraints[2].TableName);
            Assert.AreEqual("LastName", orderedConstraints[2].ColumnName);
            Assert.AreEqual(null, orderedConstraints[2].ConstraintName);
        }
コード例 #2
0
        public void GetDefaultConstraintsAsync_ArgumentNullException_DacpacPath()
        {
            // Arrange
            var        xfsMock = Mock.Of <IXmlFormatService>();
            IDacAccess da      = new DacAccess(xfsMock);

            // Act & Assert
            // ReSharper disable AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => da.GetDefaultConstraintsAsync(null));
            // ReSharper restore AssignNullToNotNullAttribute
        }
コード例 #3
0
        public async Task GetDefaultConstraintsAsync_CorrectCreation_SingleConstraints_Async()
        {
            // Arrange
            var        xfsMock        = Mock.Of <IXmlFormatService>();
            var        tempDacpacPath = WriteEmbeddedResourceToTemporaryFile("TestDatabase_AuthorWithLessDefaultConstraints.dacpac");
            IDacAccess da             = new DacAccess(xfsMock);

            // Act
            var(defaultConstraints, errors) = await da.GetDefaultConstraintsAsync(tempDacpacPath);

            // Assert
            Assert.IsNotNull(defaultConstraints);
            Assert.IsNull(errors);
            Assert.AreEqual(1, defaultConstraints.Length);
            Assert.AreEqual("dbo", defaultConstraints[0].TableSchema);
            Assert.AreEqual("Author", defaultConstraints[0].TableName);
            Assert.AreEqual("Birthday", defaultConstraints[0].ColumnName);
            Assert.AreEqual("DF_Birthday_Today", defaultConstraints[0].ConstraintName);
        }