public RouteVM() { var builder = new ContainerBuilder(); builder.RegisterType <WorkData>().As <IWorkData>(); builder.RegisterType <Engine>().As <IEngine>(); builder.RegisterType <InterAct>().As <IInterAct>(); builder.RegisterType <GraphEngine>().As <IGraphEngine>(); builder.RegisterType <Advert>().As <IAdvert>(); var container = builder.Build(); using (var scope = container.BeginLifetimeScope()) { WorkDataProp = scope.Resolve <IWorkData>(); EngineProp = scope.Resolve <IEngine>(); InteractProp = scope.Resolve <IInterAct>(); GraphEngineProp = scope.Resolve <IGraphEngine>(); AdvertProp = scope.Resolve <IAdvert>(); } WorkDataProp.LoadData(); //EngineProp = ServiceLocator.Current.GetInstance<Engine>(); //InteractProp = ServiceLocator.Current.GetInstance<InterAct>(); MethodForFirstCommand = new FirstCommandMeth(OnOneEvenHandler); }
public static IAdvert QueryItem(int id) { var item = AllCache.Find(b => b.Id == id); if (item == null) { item = new IAdvert(); item.Title = "尚未添加"; } return(item); }
public IAdvert QueryItem(int id) { var items = AllCache.Where(b => b.Id == id); if (items.Count() == 0) { var item = new IAdvert(); item.Title = "尚未添加"; return(item); } return(items.First()); }
public void Delete_Should_ThrowNullReferenceException_WhenPassedArgumentIsNull() { // Arrange var mockedDbContext = new Mock <ICarSystemEfDbContext>(); var mockedSet = new Mock <DbSet <IAdvert> >(); // Act mockedDbContext.Setup(set => set.Set <IAdvert>()).Returns(mockedSet.Object); var mockedDbSet = new EfCarSystemDbSetCocoon <IAdvert>(mockedDbContext.Object); IAdvert entity = null; // Assert Assert.That(() => mockedDbSet.Delete(entity), Throws.InstanceOf <NullReferenceException>()); }
public void ThrowNullReferenceExceptionWhithCorrectMessage_WhenPassedArgumentIsNull() { // Arrange var mockedDbContext = new Mock <ICarAdvertsSystemDbContext>(); var mockedSet = new Mock <DbSet <IAdvert> >(); mockedDbContext.Setup(set => set.Set <IAdvert>()).Returns(mockedSet.Object); var repository = new EfGenericRepository <IAdvert>(mockedDbContext.Object); IAdvert entity = null; // Act and Assert Assert.That(() => repository.Delete(entity), Throws.ArgumentNullException.With.Message.Contains (nameof(entity))); }
public HomeController(IAdvert advert) { _advert = advert; _testname = ConfigurationManager.AppSettings["testname"]; }