示例#1
0
        public void ResourcesResourceLoadAsync()
        {
            BigResource res = new BigResource(false);

            bool loadedEnter = false;

            res.Loaded  += (a) => loadedEnter = true;
            res.Aborted += (a, e) => Assert.Fail();

            var task = res.LoadAsync();

            task.Wait();

            Assert.IsTrue(res.ImLoaded);
            Assert.IsTrue(loadedEnter);

            BigResource resFail = new BigResource(true);

            bool errorEnter = false;

            resFail.Loaded  += (a) => Assert.Fail();
            resFail.Aborted += (a, e) => errorEnter = true;

            task = resFail.LoadAsync();

            task.Wait();

            Assert.IsTrue(resFail.ImLoaded);
            Assert.IsTrue(errorEnter);
        }
示例#2
0
        public void ResourcesResourceDependencyLoadAsync()
        {
            BigResource res = new BigResource(false);

            bool firstLoadEnter = false;

            res.Loaded  += (a) => firstLoadEnter = true;
            res.Aborted += (a, e) => Assert.Fail();

            DependentResource depRes = new DependentResource(res);

            bool secondLoadEnter = false;

            depRes.Loaded  += (a) => secondLoadEnter = true;
            depRes.Aborted += (a, e) => Assert.Fail();

            depRes.Load();

            Assert.IsTrue(depRes.ImLoaded);
            Assert.IsTrue(res.ImLoaded);
            Assert.IsTrue(firstLoadEnter);
            Assert.IsTrue(secondLoadEnter);
            Assert.IsTrue(depRes.State == ResourceState.Loaded);
            Assert.IsTrue(res.State == ResourceState.Loaded);
        }
示例#3
0
 public DependentResource(BigResource dependence, bool fail = false)
     : base(fail)
 {
     Fail       = fail;
     Dependence = dependence;
 }