コード例 #1
0
        public void Setup()
        {
            var mockPerson = new Mock <IPerson>();

            mockPerson.SetupAllProperties();
            mockPerson.SetupProperty(p => p.Name, "Marcus");
            mockPerson.SetupProperty(p => p.Id, 1337);
            mockPerson.SetupProperty(p => p.BirthDate, new System.DateTime(1970, 6, 20));
            person = (IPerson)mockPerson.Object;

            var mockPeopleHelper = new Mock <IPeopleHelper>();

            mockPeopleHelper.Setup(p => p.GetAge(It.IsAny <IPerson>())).Returns(50);
            peopleHelper = mockPeopleHelper.Object;

            var mockPeopleHandler = new Mock <IPeopleHandler>();

            mockPeopleHandler.Setup(m => m.People).Returns(new System.Collections.Generic.List <IPerson>
            {
                new Person {
                    Name = "Marcus"
                },
                new Person {
                    Name = "James Sunderland"
                },
                new Person {
                    Name = "Henry Townsend"
                },
            });
            mockPeopleHandler.Setup(f => f.FindPerson(It.IsAny <string>())).Returns(new Person {
                Name = "Pyramid Head"
            });
            peopleHandler = mockPeopleHandler.Object;
        }
コード例 #2
0
 public PlanetHelper(ICommonUrlHelper commonUrlHelper,
                     IPlanetRequestHelper planetRequestHelper,
                     IPlanetDecoratorHelper planetDecoratorHelper,
                     IPeopleHelper peopleHelper)
 {
     _commonUrlHelper            = commonUrlHelper;
     _planetRequestHelper        = planetRequestHelper;
     _planetModelDecoratorHelper = planetDecoratorHelper;
     _peopleHelper = peopleHelper;
 }