Exemple #1
0
        public void CanRemoveLabelFromClients()
        {
            var labelRepository = new LocalRepository <Label>();

            labelRepository.Add(new Label()
            {
                Id = 1, Name = "Label 1"
            });
            Label label2 = new Label()
            {
                Id = 2, Name = "Label 2"
            };

            labelRepository.Add(label2);
            labelRepository.Add(new Label()
            {
                Id = 3, Name = "Label 3"
            });

            var clientRepository = new LocalRepository <Client>();

            Client client1 = ModelHelper.TestClient1AllDataNoReferences;

            client1.Labels.Add(label2);

            Client client2 = ModelHelper.TestClient2AllDataNoReferences;

            client2.Labels.Add(label2);

            clientRepository.Add(client1);
            clientRepository.Add(client2);

            var controller = new LabelController(labelRepository, clientRepository);

            LeadSetPostValues leadSetPostValues = new LeadSetPostValues();

            leadSetPostValues.clientIds = new List <int>()
            {
                client1.Id, client2.Id
            };
            leadSetPostValues.labelId = 2;

            controller.Set(leadSetPostValues);

            Assert.IsFalse(client1.Labels.Any(l => l.Name == "Label 2"));
            Assert.IsFalse(client2.Labels.Any(l => l.Name == "Label 2"));
        }