public void controllers_name_should_end_with_Controller() { var controllers = ConventionsHelper.classes() .Where(x => x.IsAssignableTo <Controller>()) .ToList(); Assert.NotEmpty(controllers); foreach (var controller in controllers) { Assert.EndsWith("Controller", controller.Name); } }
public void each_class_in_DataAccess_namespace_implements_interface() { var data_access_classes = ConventionsHelper.classes() .Where(x => x.Namespace.Contains(".DataAccess")) .ToList() ; Assert.NotEmpty(data_access_classes); var data_access_without_interfaces = data_access_classes .Where(x => x.GetInterfaces().Length == 0) ; Assert.Empty(data_access_without_interfaces); }
public void each_interface_has_at_least_one_implementation() { var interfaces = ConventionsHelper.interfaces() .Where(x => x.Namespace.Contains("._Infrastructure") == false) .ToList(); var concrete_types = ConventionsHelper.classes() .Where(x => x.IsConcrete()) .ToList(); foreach (var @interface in interfaces) { var types_assignable_to_interface = concrete_types .Where(x => @interface.IsAssignableFrom(x)); Assert.NotEmpty(types_assignable_to_interface); } }
public void each_command_has_exactly_one_handler() { var commands = ConventionsHelper.classes() .Where(x => x.IsAssignableTo <ICommand>()) .ToList(); var handlers = ConventionsHelper.classes() .Where(x => x.IsAssignableTo <IHandleCommand>()) .ToList(); Assert.NotEmpty(commands); foreach (var command in commands) { var handler_type = typeof(IHandleCommand <>).MakeGenericType(command); var command_handlers = handlers.Where(x => x.GetInterfaces().Contains(handler_type)); Assert.Equal(1, command_handlers.Count()); } }