Ejemplo n.º 1
0
        public void Create()
        {
            // Arrange
            var countSets = _sets.Count;
            var newSet    = new SetDTO
            {
                PlannedTime = 1800,
                TimeForRest = 90,
            };

            _mock.Setup(s => s.Create(It.IsAny <SetDTO>())).Returns <SetDTO>(newItem =>
            {
                newItem.Id           = _sets.Count + 1;
                newItem.CreatedDate  = DateTime.Now;
                newItem.ModifiedDate = DateTime.Now;

                _sets.Add(newItem);

                return(newItem.Id);
            });

            // Act
            var result = _setService.Create(newSet);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IOperationResult));
            Assert.AreEqual(countSets + 1, _sets.Count);
            Assert.IsTrue(result.Succeed);
            Assert.IsTrue(result.ResultItemId > 0);
        }