Esempio n. 1
0
        internal static Asset AsModel(this DAL.Entities.Asset entity)
        {
            Assert.IsNotNull(entity, "entity");

            return(new Asset
            {
                Id = entity.Id,
                DeckType = entity.DeckType.AsModel(),
                InspectionDate = entity.InspectionDate.HasValue ? entity.InspectionDate.Value.ToString("yyyy-MM-dd") : "",
                InspectionNumber = entity.InspectionNumber,
                IsHighwayBridge = entity.IsHighwayBridge,
                IsMaintenanceRequired = entity.IsMaintenanceRequired,
                Name = entity.Name,
                Owner = entity.Owner,
                StructureNumber = entity.StructureNumber
            });
        }
        public void ExampleOfBasicIdUnitTest()
        {
            // Arrange
            var mockLogger            = new Mock <ILog>();
            var mockRickettyBridgeDal = new Mock <IRickettyBridgeService>();
            var returnedAsset         = new DAL.Entities.Asset {
                Id = 22, Name = "Test Returned Name", DeckType = new DeckType()
            };

            mockRickettyBridgeDal.Setup(x => x.GetAsset(22)).Returns(returnedAsset);

            AssetController controller = new AssetController(mockLogger.Object, mockRickettyBridgeDal.Object);

            // Act
            var result = controller.Id(22);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(22, result.Id);
            Assert.AreEqual("Test Returned Name", result.Name);
        }