示例#1
0
        public void SetUp()
        {
            factory = new MockFactory();
            sensor  = factory.CreateMock <AbstractTouchSensor>();
            prompt  = factory.CreateMock <TextControl>();
            prompt.Expects.One.Method(_ => _.show());
            prompt.Expects.One.Method(_ => _.hide());
            prompt.Expects.One.Method(_ => _.setText("")).With(Is.TypeOf(typeof(String)));

            sprite = factory.CreateMock <Sprite>();

            messageBox = factory.CreateMock <AbstractMessageBox>();
            messageBox.Expects.One.Method(_ => _.setMessage("")).With(Is.TypeOf(typeof(String)));
            messageBox.Expects.One.Method(_ => _.hide());
            messageBox.Expects.One.Method(_ => _.show());
            gameObject = factory.CreateMock <GameObject>();
            gameObject.Expects.Any.Method(_ => _.GetComponent <Sprite>()).WillReturn(sprite.MockObject);
        }
示例#2
0
        public void Test_Avatar_SetState()
        {
            var avatarGO = MockFactory.CreateAvatarGameObject("MyAvatar");
            var avatar   = avatarGO.GetComponent <WM.Net.Avatar>();

            var avatarState1 = new AvatarState();

            avatarState1.HeadPosition = new Vector3(1, 2, 3);
            avatar.SetState(avatarState1);
            Assert.IsTrue(avatar.GetState().Equals(avatarState1));

            var avatarState2 = new AvatarState();

            avatarState2.HeadPosition = new Vector3(4, 5, 6);
            avatar.SetState(avatarState2);
            Assert.IsTrue(avatar.GetState().Equals(avatarState2));

            var avatarState3 = new AvatarState();

            avatarState2.HeadPosition = new Vector3(7, 8, 9);
            avatar.SetState(avatarState3);
            Assert.IsTrue(avatar.GetState().Equals(avatarState3));
        }
        public static Mock <AttributeSet> CreateAttributeSet(AttributeSetContainer container, AttributeSets parent)
        {
            var attMock = new Mock <AttributeSet>();

            attMock.Setup(x => x.Name).Returns(container.Name);
            attMock.As <AttributeSet>().Setup(x => x.Count).Returns(() =>
            {
                return(container.Attributes.Count);
            });
            attMock.Setup(m => m[It.IsAny <int>()]).Returns <int>(i => container.Attributes.ElementAt(i).Value);
            attMock.As <IEnumerable>().Setup(m => m.GetEnumerator()).Returns(() => container.Attributes.GetEnumerator());
            attMock.Setup(x => x.Add(It.IsAny <string>(), It.IsAny <ValueTypeEnum>(), It.IsAny <object>()))
            .Returns <string, ValueTypeEnum, object>(
                (s, v, o) =>
            {
                var item = MockFactory.CreateAttribute(s, v, o, attMock.Object);
                container.Attributes.Add(item);
                return(item);
            });
            attMock.Setup(x => x.get_NameIsUsed(It.IsAny <string>())).Returns <string>(r => container.Attributes.Any(y => y.Name == r));
            attMock.Setup(x => x.Parent).Returns(parent);
            return(attMock);
        }
示例#4
0
 public void SetUp()
 {
     factory             = new MockFactory();
     camera              = factory.CreateMock <Camera>();
     inputReturningTouch = inputReturningMockTouch();
 }
示例#5
0
 public void SetUp()
 {
     factory      = new MockFactory();
     loopTracker  = factory.CreateMock <AbstractLoopTracker>();
     sceneFactory = factory.CreateMock <AbstractSceneFactory>();
 }