예제 #1
0
        public virtual SourceResultDataContract InsertManualDataSource(ManualDataContract source)
        {
            var manualData = new ManualDataSource
                {
                    DateEdit = DateTime.Now,
                    InputStatus = SourceStatus.PendingCalculation,
                    ReferenceNotes = source.ReferenceNotes,
                    UserName = source.UserName,
                    DisplayType = source.DisplayType
                };

            manualData = Context.AddDataSource(manualData);
            return DataContractSuccess(manualData.Id);
        }
예제 #2
0
 public virtual async Task<IHttpActionResult> InsertManualDataSource(ManualDataContract source)
 {
     source.UserName = User.Identity.Name;
     var result = await Task.Run(() => dataService.InsertManualDataSource(source));
     return Ok(result);
 }
        public void InsertManualDataSourceMustCallAddDataSource()
        {
            //Arrange
            var contract = new ManualDataContract
                {
                    ReferenceNotes = "reference notes"
                };
            CreateService();
            mockContext
                .Setup(context => context.AddDataSource(It.Is<ManualDataSource>(
                    source =>
                    (source.InputStatus == SourceStatus.PendingExtraction) &&
                    (source.ReferenceNotes == "reference notes") &&
                    (source.UserName == "TestUserName"))))
                .Returns(new ManualDataSource {Id = newSourceId})
                .Verifiable();

            //Act
            var result = mockService.Object.InsertManualDataSource(contract);

            //Assert
            mockContext.Verify();
            Assert.AreEqual(newSourceId, result.SourceId);
            Assert.AreEqual(0, result.ErrorMessages.Count);
            Assert.IsTrue(result.Succeeded);
        }