public void BindCommands() { // Arrange var modelsAssembly = Assembly.Load(new AssemblyName(CqrsBindingsTests._modelAssembly)); var dalAssembly = Assembly.Load(new AssemblyName(CqrsBindingsTests._dataAccessAssembly)); var bindings = new CqrsBindings(); // Act bindings.CollectCommands(modelsAssembly); bindings.BindCommandHandlers(dalAssembly); // Assert Assert.True(bindings.Validate()); Assert.NotNull(bindings.CommandBindings); Assert.True(bindings.CommandBindings.Any()); foreach (var command in bindings.CommandBindings) { foreach (var handler in command.Handlers) { var genType = typeof(ICommandHandler <>).MakeGenericType(command.Command); Assert.True(genType.IsAssignableFrom(handler)); } } }
public void BindQueries() { // Arrange var modelsAssembly = Assembly.Load(new AssemblyName(CqrsBindingsTests._modelAssembly)); var dalAssembly = Assembly.Load(new AssemblyName(CqrsBindingsTests._dataAccessAssembly)); var bindings = new CqrsBindings(); // Act bindings.CollectQueryInterfaces(modelsAssembly); bindings.BindQueries(dalAssembly); // Assert Assert.True(bindings.Validate()); Assert.NotNull(bindings.QueryBindings); Assert.True(bindings.QueryBindings.Any()); foreach (var query in bindings.QueryBindings) { Assert.True(query.Interface.IsAssignableFrom(query.Implementation)); } }