コード例 #1
0
        public void ProcessDependentOpResults_SucceedsOnNoErrorMessage()
        {
            var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string));
            var localHashLoc  = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string));
            var catalogLoc    = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider),
                                                         typeof(IResourceLocator), remoteHashLoc, localHashLoc);

            var op1     = new ExceptionTestOperation(null, "good result", true);
            var handle1 = new AsyncOperationHandle(op1);
            var results = new List <AsyncOperationHandle>();

            var loc      = new TestLocator(kLocatorId);
            var locInfo  = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc);
            var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>();

            locInfos.Add(locInfo);

            var trivialHashes = new List <string>(new[] { "same" });

            results.Add(handle1);
            bool   success;
            string errorString;
            var    result =
                CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString,
                                                                 out success);

            Assert.AreEqual(true, success, "Operation should succeed when underlying operation op1 has a null OperationException");
            Assert.IsNull(errorString, "Error string should be null when operation is succeeding without errors.");
            Assert.NotNull(result, "Result should only be null when every operation within it fails.");
        }
コード例 #2
0
        public void ProcessDependentOpResults_FailsWithErrorMessageOnInternalError()
        {
            var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string));
            var localHashLoc  = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string));
            var catalogLoc    = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider),
                                                         typeof(IResourceLocator), remoteHashLoc, localHashLoc);

            var op1     = new ExceptionTestOperation(new Exception("Bad operation"), null);
            var handle1 = new AsyncOperationHandle(op1);
            var results = new List <AsyncOperationHandle>();

            var loc      = new TestLocator(kLocatorId);
            var locInfo  = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc);
            var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>();

            locInfos.Add(locInfo);

            var trivialHashes = new List <string>(new[] { "badHash" });

            results.Add(handle1);
            bool   success;
            string errorString;
            var    result =
                CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString,
                                                                 out success);

            LogAssert.Expect(LogType.Error, "System.Exception: Bad operation");
            Assert.AreEqual(false, success, "Operation should not succeed when underlying operation op1 has a non null OperationException");
            Assert.AreEqual(true, errorString.Contains("Bad operation"), "Error string should contain the error message thrown by the underlying operation");
            Assert.IsNull(result, "Result should be null in the case where every operation within it failed.");
        }
コード例 #3
0
        public void ProcessDependentOpResults_ReturnsFailureOnOneErrorMessage()
        {
            var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string));
            var localHashLoc  = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string));
            var catalogLoc    = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider),
                                                         typeof(IResourceLocator), remoteHashLoc, localHashLoc);

            var op1     = new ExceptionTestOperation(null, "good result", true);
            var op2     = new ExceptionTestOperation(new Exception("Bad operation"), null);
            var handle1 = new AsyncOperationHandle(op1);
            var handle2 = new AsyncOperationHandle(op2);
            var results = new List <AsyncOperationHandle>();

            results.Add(handle1);
            results.Add(handle2);

            var loc      = new TestLocator(kLocatorId);
            var locInfo1 = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc);
            var locInfo2 = new AddressablesImpl.ResourceLocatorInfo(loc, "bad", catalogLoc);
            var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>();

            locInfos.Add(locInfo1);
            locInfos.Add(locInfo2);

            var trivialHashes = new List <string>(new[] { "same", "good" });

            bool   success;
            string errorString;
            var    result =
                CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString,
                                                                 out success);

            LogAssert.Expect(LogType.Error, "System.Exception: Bad operation");
            Assert.AreEqual(false, success, "Operation should fail when underlying operation op1 has a null OperationException, even if op2 has a non null OperationException");
            Assert.AreEqual(true, errorString.Contains("Bad operation"), "Error string should contain the error message thrown by the underlying operation");
            Assert.NotNull(result, "Result should only be null if every underlying operation fails.");
            Assert.NotNull(result[0], "Only failed operations should be null in the result list.");
            Assert.IsNull(result[1], "Failed operations should be null in the result list.");
        }