コード例 #1
0
    public void Test_Store_Same_entry_With_Versions()
    {
        // create storage
        FileCacheStorage storage = new FileCacheStorage(_curDir, _curFile, _fileSystemMock.Object, _serializerMock.Object);

        string id       = "1";
        string version1 = "1.1";
        string version2 = "2.0";

        // store the data with id and version1
        storage.Set(_data, id, version1);

        // store the data with id and version2
        storage.Set(_data, id, version2);

        // check version of the FileCacheEntry with id in the storage
        Assert.AreEqual(true, storage.Has(id));
        Assert.AreEqual(true, storage.MatchesVersion(id, version2));
        Assert.AreEqual(false, storage.MatchesVersion(id, version1));

        string version3 = "3.0";

        // store the data with id and version3
        storage.Set(_data, id, version3);

        // check version of the FileCacheEntry with id in the storage
        Assert.AreEqual(true, storage.MatchesVersion(id, version3));
    }
コード例 #2
0
    public void Test_CheckVersioning()
    {
        string           version1 = "1.1";
        FileCacheStorage storage  = createAndFillStorage(4, version1);

        string id       = "1";
        string version2 = "2.0";

        // change version for id
        storage.Set(_data2, id, version2);
        // check if version changed
        Assert.AreEqual(true, storage.MatchesVersion(id, version2));
        // check old version
        Assert.AreEqual(false, storage.MatchesVersion(id, version1));
    }