public void AddMany(this OneClass self, params object[] items) { foreach (object item in items) { self.Items.Add(item); } }
public void Start() { if (_whatToCreate > 0) { One = new OneClass(new OtherClass()); } else { One = new OneClass(new OtherClass2()); } One.PerformSomething(); }
public void Test1() { var one = new OneClass(); var eventType = typeof(OneClass).GetEvent(nameof(OneClass.OnEvent)); var functionType = typeof(OneClass).GetMethod(nameof(OneClass.Func)); one.OnEvent += OneClass.Func; eventType.AddEvent(one, functionType); var list = new List <DateTime>(); one.CallEvent(list); Assert.Equal(2, list.Count); }
public async Task Should_Invoke_Callback() { //Arrange var someService = Substitute.For <ISomeService>(); OneClass one = new OneClass(); TwoClass two = new TwoClass(); someService .UpdateAsync(Arg.Do <Action <OneClass, TwoClass> >(action => action(one, two))) .Returns(Task.CompletedTask); bool invoked = false; Action <OneClass, TwoClass> callback = (a, b) => { invoked = a != null && b != null; }; //Act await someService.UpdateAsync(callback); //Assert - using FluentAssertions invoked.Should().BeTrue(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); OneClass oc = new OneClass(); int y = Convert.ToInt32(oc); }