Example #1
0
        public void CreateRemoteObjectsSuccess()
        {
            var remoteObjects = RemoteObjectUtils.CreateRemoteObjects(
                factory.Create,
                factory.Delete,
                handles);

            CollectionAssert.AreEqual(new[] { obj1, obj2, obj3, null }, remoteObjects);
        }
Example #2
0
        public void CreateRemoteObjectsThrowsErrorAndEitherCreatesOrDeletesAllObjects()
        {
            factory.Create(handle2).Returns(_ => { throw new CreateExceptionFake(); });

            Assert.Throws <CreateExceptionFake>(() => RemoteObjectUtils.CreateRemoteObjects(
                                                    factory.Create, factory.Delete, handles));

            factory.Received().Create(handle1);
            factory.DidNotReceive().Delete(handle1);

            factory.Received().Create(handle2);
            factory.Received().Delete(handle2);

            factory.DidNotReceive().Create(handle3);
            factory.Received().Delete(handle3);
        }
Example #3
0
        public void CreateRemoteObjectsWhenCreateReturnsNull()
        {
            factory.Create(handle1).Returns((RemoteObjectFake)null);

            Assert.Throws <InvalidOperationException>(() => RemoteObjectUtils.CreateRemoteObjects(
                                                          factory.Create, factory.Delete, handles));

            factory.Received().Create(handle1);
            factory.Received().Delete(handle1);

            factory.DidNotReceive().Create(handle2);
            factory.Received().Delete(handle2);

            factory.DidNotReceive().Create(handle3);
            factory.Received().Delete(handle3);
        }
Example #4
0
        public void CreateRemoteObjectsCatchesDeleteException()
        {
            factory.Create(handle1).Returns(_ => { throw new CreateExceptionFake(); });
            factory.When(x => x.Delete(handle2)).Do(_ => { throw new DeleteExceptionFake(); });

            Assert.Throws <CreateExceptionFake>(() => RemoteObjectUtils.CreateRemoteObjects(
                                                    factory.Create, factory.Delete, handles));

            factory.Received().Create(handle1);
            factory.Received().Delete(handle1);

            factory.DidNotReceive().Create(handle2);
            factory.Received().Delete(handle2);

            factory.DidNotReceive().Create(handle3);
            factory.Received().Delete(handle3);
        }