コード例 #1
0
        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            MockRepository mocks             = new MockRepository();
            ISomeService   m_SomeServiceMock = mocks.StrictMock <ISomeService>();
            SomeClient     sut = new SomeClient(m_SomeServiceMock);

            using (mocks.Ordered())
            {
                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething <string>(null, null);
                });
                LastCall.IgnoreArguments();

                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething <DateTime>(null, default(DateTime));                     // can't use null here, because it's a value type!
                });
                LastCall.IgnoreArguments();
            }
            mocks.ReplayAll();

            // test
            sut.DoSomething();

            // verification
            mocks.VerifyAll();

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
コード例 #2
0
        public void UnexpectedCallToGenericMethod()
        {
            MockRepository mocks             = new MockRepository();
            ISomeService   m_SomeServiceMock = mocks.StrictMock <ISomeService>();

            m_SomeServiceMock.DoSomething <string>(null, "foo");
            mocks.ReplayAll();
            Assert.Throws <ExpectationViolationException>(
                @"ISomeService.DoSomething<System.Int32>(null, 5); Expected #0, Actual #1.
ISomeService.DoSomething<System.String>(null, ""foo""); Expected #1, Actual #0.",
                () => m_SomeServiceMock.DoSomething <int>(null, 5));
        }
コード例 #3
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req)
        {
            _logger.LogInformation("C# HTTP trigger function processed a request.");


            _otherClass.DoSomething();

            return((ActionResult) new OkObjectResult($"ok"));
        }
コード例 #4
0
        public void UnexpectedCallToGenericMethod()
        {
            ISomeService m_SomeServiceMock = MockRepository.Mock <ISomeService>();

            m_SomeServiceMock.Expect(x => x.DoSomething <string>(null, "foo"));

            m_SomeServiceMock.DoSomething <int>(null, 5);

            Assert.Throws <ExpectationViolationException>(
                () => m_SomeServiceMock.VerifyExpectations(true));
        }
コード例 #5
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
            ISomeService someService,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            someService.DoSomething();

            return(new OkResult());
        }
コード例 #6
0
 public Task MyMethod()
 {
     return(Task.Run(() =>
     {
         var success = _someService.DoSomething();
         if (!success)
         {
             throw new Exception("unsuccsesfull");
         }
     }));
 }
コード例 #7
0
        private static void Main(string[] args)
        {
            var sessionModel = new SessionModel(3);
            // first case (see text down below):

            var compositionContainer = new CompositionContainer();

            // second case (see text down below):
            //var typeCatalog = new TypeCatalog(typeof (SessionModel));
            //var compositionContainer = new CompositionContainer(typeCatalog);
            //compositionContainer.ComposeExportedValue(sessionModel);
            ISomeService someService = sessionModel.GetExport <ISomeService>("SomeService", sessionModel.cname);

            someService.DoSomething();
        }
コード例 #8
0
        private static void Main(string[] args)
        {
            var catalogs = new AggregateCatalog();
            var catalog  = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(Assembly.GetExecutingAssembly());

            catalogs.Catalogs.Add(catalog);
            var          sessionModel = new SessionModel(3);
            var          container    = new CompositionContainer(catalog);
            ISomeService someService  = container.GetExportedValueOrDefault <ISomeService>(sessionModel.cname);

            if (someService != null)
            {
                someService.DoSomething();
            }
        }
コード例 #9
0
        public void DoSomething()
        {
            m_SomeSvc.DoSomething <string>("string.test", "some string");

            m_SomeSvc.DoSomething <DateTime>("struct.test", DateTime.Now);
        }
コード例 #10
0
ファイル: Wildcard.cs プロジェクト: mujdatdinc/moq4
 public void DoSomething_MixedTypes()
 {
     mock.Setup(obj => obj.DoSomething(_, _, _)).Returns(444);
     Assert.Equal(444, obj.DoSomething(null, GearId.Neutral, 1));
 }
コード例 #11
0
 public void Run()
 {
     _logger.LogInformation("Run started");
     _someService.DoSomething(_configuration.GetValue <string>("Location"));
 }
コード例 #12
0
 public void Apply(ActionModel actionModel)
 {
     someService.DoSomething();
コード例 #13
0
 public void Do()
 {
     _someService.DoSomething();
 }