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; }
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)); }
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")); }
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)); }
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()); }
public Task MyMethod() { return(Task.Run(() => { var success = _someService.DoSomething(); if (!success) { throw new Exception("unsuccsesfull"); } })); }
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(); }
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(); } }
public void DoSomething() { m_SomeSvc.DoSomething <string>("string.test", "some string"); m_SomeSvc.DoSomething <DateTime>("struct.test", DateTime.Now); }
public void DoSomething_MixedTypes() { mock.Setup(obj => obj.DoSomething(_, _, _)).Returns(444); Assert.Equal(444, obj.DoSomething(null, GearId.Neutral, 1)); }
public void Run() { _logger.LogInformation("Run started"); _someService.DoSomething(_configuration.GetValue <string>("Location")); }
public void Apply(ActionModel actionModel) { someService.DoSomething();
public void Do() { _someService.DoSomething(); }