Exemple #1
0
        public void AddOperation_Should_Save()
        {
            var sampleRemoteOp = new RemoteEntities.UserOperation()
            {
                FirstNumber = "1", SecondNumber = "2", Operation = "1",
            };
            var sampleOp = new Entities.UserOperation()
            {
                FirstNumber = "1", SecondNumber = "2", Operation = "1",
            };

            _validationMock.Setup(m => m.Validate(It.IsAny <RemoteEntities.UserOperation>()))
            .Returns(true);
            _userOpRepoMock.Setup(m => m.Add(It.IsAny <Entities.UserOperation>()))
            .Returns(sampleOp).Verifiable();

            //Act
            var newOp = _service.AddOperation(sampleRemoteOp);

            //Assert
            newOp.Should().NotBeNull();
            newOp.Should().BeOfType <RemoteEntities.UserOperation>();
            _calcMock.Verify(m => m.Calculate <long>(It.IsAny <RemoteEntities.UserOperation>()), Times.Once);
            _userOpRepoMock.VerifyAll();
        }
Exemple #2
0
        public static RemoteEntities.UserOperation ToRemote(this Entities.UserOperation source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new RemoteEntities.UserOperation
            {
                Id = source.Id,
                FirstNumber = source.FirstNumber,
                Operation = source.Operation,
                Result = source.Result,
                SecondNumber = source.SecondNumber,
                UserId = source.UserId,
            });
        }