public void ChangeEnableTest() { // Создадим пользователя var account = TestHelper.GetTestAccount(); var user = TestHelper.CreateTestUser(account.Id); var dispatcher = TestHelper.GetDispatcherClient(); // Создадим тип компонента var componentType = TestHelper.CreateRandomComponentType(account.Id); var channels = new[] { SubscriptionChannel.Email, SubscriptionChannel.Sms, SubscriptionChannel.Http }; foreach (var channel in channels) { // Настроим подписку по умолчанию и подписку на тип var response1 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.Default, Channel = channel }); var data1 = response1.Data; var response2 = dispatcher.UpdateSubscription(account.Id, new UpdateSubscriptionRequestData() { Id = data1.Id, IsEnabled = true, Importance = EventImportance.Warning }); response2.Check(); var response3 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.ComponentType, Channel = channel, ComponentTypeId = componentType.Id }); var data3 = response3.Data; var response4 = dispatcher.UpdateSubscription(account.Id, new UpdateSubscriptionRequestData() { Id = data3.Id, IsEnabled = true, Importance = EventImportance.Warning }); response4.Check(); // Выключим обе подписки using (var controller = new SubscriptionsController(account.Id, user.Id)) { controller.Enable(data1.Id + "," + data3.Id, false, user.Id, channel); } // Проверим, что подписки выключены var response5 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.Default, Channel = channel }); var data5 = response5.Data; Assert.False(data5.IsEnabled); var response6 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.ComponentType, ComponentTypeId = componentType.Id, Channel = channel }); var data6 = response6.Data; Assert.False(data6.IsEnabled); // Включим обе подписки using (var controller = new SubscriptionsController(account.Id, user.Id)) { controller.Enable(data1.Id + "," + data3.Id, true, user.Id, channel); } // Проверим, что подписки включены var response7 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.Default, Channel = channel }); var data7 = response7.Data; Assert.True(data7.IsEnabled); var response8 = dispatcher.CreateSubscription(account.Id, new CreateSubscriptionRequestData() { UserId = user.Id, Object = SubscriptionObject.ComponentType, Channel = channel, ComponentTypeId = componentType.Id }); var data8 = response8.Data; Assert.True(data8.IsEnabled); } }