コード例 #1
0
        public void GetById_Throw_ArgumentOutOfRangeException_OnNegativeId()
        {
            const int id      = -5;
            var       service = new RecipientsDataInMemory();

            service.GetById(id);
        }
コード例 #2
0
        public void Add_Method_AddNewItemService()
        {
            //AAA
            //Arange
            string expected_name  = "testRecepient";
            string expected_email = "Test email";
            var    new_recepient  = new Recipient
            {
                Name  = expected_name,
                Email = expected_email
            };

            var service = new RecipientsDataInMemory();

            //Act

            var actual_id = service.Add(new_recepient);

            //Assert
            Assert.AreEqual(new_recepient.Id, actual_id);
            Assert.IsTrue(service.GetAll().Contains(new_recepient));


            if (service.GetById(new_recepient.Id) != new_recepient)
            {
                throw new AssertFailedException("В сервисе под указанным идентификатором хранится неверная сущность");
            }
        }
コード例 #3
0
        public void GetById_ReturnCorrectItem()
        {
            const string expected_name  = "Test Recipient";
            const string expected_email = "Test email";
            var          new_recipient  = new Recipient
            {
                Name  = expected_name,
                Email = expected_email
            };

            var service = new RecipientsDataInMemory();

            var max_id = service.GetAll().Max(recipient => recipient.Id);

            var actual_id = service.Add(new_recipient);

            var expected_id = max_id + 1;

            //Assert.AreEqual(expected_id, actual_id);
            //Assert.AreEqual(expected_id, new_recipient.Id);

            var actual_recipient = service.GetById(expected_id);

            Assert.AreEqual(new_recipient, actual_recipient);
        }