public void QueryAll_WithOne_ReturnsOne() { Notification notification; NotificationQueryHandler handler; NotificationQuery.Response response; Scenario() .Given(notification = new Notification()) .Given(handler = NewHandler().WithNotifications(notification)) .When(response = handler.Handle(new NotificationQuery())) .Then(ExpectThat(response), Is(ANotificationQueryResponse.With().Result(ANotification.Instance(notification)))); }
static void Main(string[] args) { ANotification objectNotification = new ANotification(); //A 观察者 AObserver a = new AObserver(objectNotification, "观察者A"); BObserver b = new BObserver(objectNotification, "观察者B"); //关联事件 objectNotification.Update += new ExecuteTask(a.AMethod); objectNotification.Update += new ExecuteTask(b.BMethod); //准备消息 objectNotification.PublishedMessage = "设备水位低于标准水位!"; //消息发出 objectNotification.Notify(); Console.Read(); }