public void ConcreteImplementation() { // Create your concrete implementation var fizz = new Fizz(3); var buzz = new Buzz(5); // Set it as the implementation of an interface _moq.Use <IFizz>(fizz); _moq.Create <FizzBuzzGame>().Fizz.Should().BeSameAs(fizz); // Or use for all interfaces _moq.Use(buzz).ForAllImplementedInterfaces(); _moq.Create <FizzBuzzGame>().Buzz.Should().BeSameAs(buzz); // Allow you to set a default value for value types _moq.Use(25); _moq.Create <Fizz>().Divisor.Should().Be(25); // Allow you to set a default value for reference types _moq.Use("GitHub"); _moq.Create <StringCtor>().Text.Should().Be("GitHub"); // ### Shortcuts // Shortcut for creating a concrete type, and using this instance for all implemented interfaces. // e.g. syntactic sugar for _moq.Use(_moq.Create<Leaf>).ForAllImplementedInterfaces() var leaf = _moq.Use <Leaf>(); _moq.Create <Branch>().Leaf.Should().BeSameAs(leaf); }
public void ConcreteImplementation() { // Create your concrete implementation var fizz = new Fizz(3); var buzz = new Buzz(5); // Set it as the implementation of an interface _moq.Use <IFizz>(fizz); _moq.Create <FizzBuzzGame>().Fizz.Should().BeSameAs(fizz); // Or use for all interfaces _moq.Use(buzz).ForAllImplementedInterfaces(); _moq.Create <FizzBuzzGame>().Buzz.Should().BeSameAs(buzz); // Allow you to set a default value for value types _moq.Use(25); _moq.Create <Fizz>().Divisor.Should().Be(25); // Allow you to set a default value for reference types _moq.Use("GitHub"); _moq.Create <StringCtor>().Text.Should().Be("GitHub"); }