Ejemplo n.º 1
0
    public IEnumerator SingleMemoryRequest()
    {
        int testAddress = 0;

        // create two mock layers
        MemoryLayer upperLayer = MockLayer(new Vector3(50, 0, 50));
        MemoryLayer lowerLayer = MockLayer(new Vector3(0, 0, 50));

        // release for a frame so that start can be called on the layers
        yield return(null);

        // associate the layers with eachother
        upperLayer.layerBelow = lowerLayer;
        lowerLayer.layerAbove = upperLayer;

        // set the layer latencies to 1 which will make the packets arrive in a single update
        upperLayer.layerLatency = 1;
        lowerLayer.layerLatency = 1;

        // add some memory addresses to the upper layer
        upperLayer.AddMemoryLocation(testAddress);

        // make some requests on the lower layer
        lowerLayer.MakeRequest(testAddress);

        // wait until the request has been fulfilled
        yield return(new WaitForSeconds(1));

        // Check that the lower layer now has the address in its list
        Assert.IsTrue(lowerLayer.CheckForAddress(testAddress) >= 0);
    }
Ejemplo n.º 2
0
    public IEnumerator ElementReplacement()
    {
        // setup the layers
        MemoryLayer upperLayer = MockLayer(new Vector3(50, 0, 50));
        MemoryLayer lowerLayer = MockLayer(new Vector3(0, 0, 50));

        // release for a frame so that start can be called on the layers
        yield return(null);

        // associate the layers with eachother
        upperLayer.layerBelow = lowerLayer;
        lowerLayer.layerAbove = upperLayer;

        // set the layer latencies to 1 which will make the packets arrive in a single update
        upperLayer.layerLatency = 1;
        lowerLayer.layerLatency = 1;

        // add addresses to the upper layer
        upperLayer.AddMemoryLocation(0);
        upperLayer.AddMemoryLocation(1);
        upperLayer.AddMemoryLocation(2);
        upperLayer.AddMemoryLocation(3);
        upperLayer.AddMemoryLocation(4);

        // set the size of the lower layer to 3
        lowerLayer.SetSize(3);

        // make three calls to fill the lower layer
        lowerLayer.MakeRequest(0);
        lowerLayer.MakeRequest(1);
        lowerLayer.MakeRequest(2);

        // wait for the requests to be handled
        yield return(new WaitForSeconds(1));

        // make a new request which should cause a replacement
        lowerLayer.MakeRequest(3);

        // wait for the request to be handled
        yield return(new WaitForSeconds(1));

        // the lower layer should now contain the most recently requseted address
        Assert.IsTrue(lowerLayer.CheckForAddress(3) >= 0);
        // it should also only contain three elements
        Assert.IsTrue(3 == lowerLayer.memoryLocations.Count);
    }