Ejemplo n.º 1
0
        public void DataUsedAsReadOnly_DoNotAffectDataOwnership()
        {
            var reservedQueryID = QueryMatchID.Generate();
            var sharedQueryID   = QueryMatchID.Generate();
            var readOnlyQueryID = QueryMatchID.Generate();

            Assert.True(m_Db.DataAvailableForUse(k_DataID, reservedQueryID.queryID, Exclusivity.Reserved));
            Assert.True(m_Db.DataAvailableForUse(k_DataID, sharedQueryID.queryID, Exclusivity.Shared));
            Assert.True(m_Db.DataAvailableForUse(k_DataID, readOnlyQueryID.queryID, Exclusivity.ReadOnly));

            m_Db.MarkDataUsedForUpdates(k_DataID, reservedQueryID, Exclusivity.Reserved);
            Assert.False(m_Db.DataAvailableForUse(k_DataID, reservedQueryID.queryID, Exclusivity.Reserved));
            Assert.False(m_Db.DataAvailableForUse(k_DataID, sharedQueryID.queryID, Exclusivity.Shared));
            Assert.True(m_Db.DataAvailableForUse(k_DataID, readOnlyQueryID.queryID, Exclusivity.ReadOnly));

            m_Db.MarkDataUsedForUpdates(k_DataID, readOnlyQueryID, Exclusivity.ReadOnly);
            Assert.False(m_Db.DataAvailableForUse(k_DataID, reservedQueryID.queryID, Exclusivity.Reserved));
            Assert.False(m_Db.DataAvailableForUse(k_DataID, sharedQueryID.queryID, Exclusivity.Shared));
            // since we previously marked this query as using this data, even though it's read only,
            // it should now not be available for use
            Assert.False(m_Db.DataAvailableForUse(k_DataID, readOnlyQueryID.queryID, Exclusivity.ReadOnly));

            m_Db.UnmarkDataUsedForUpdates(readOnlyQueryID);
            Assert.False(m_Db.DataAvailableForUse(k_DataID, reservedQueryID.queryID, Exclusivity.Reserved));
            Assert.False(m_Db.DataAvailableForUse(k_DataID, sharedQueryID.queryID, Exclusivity.Shared));
            // available for use again now that this query isn't using it
            Assert.True(m_Db.DataAvailableForUse(k_DataID, readOnlyQueryID.queryID, Exclusivity.ReadOnly));
        }