示例#1
0
        public static List <Mock> MockUtilities()
        {
            var mocks       = new List <Mock>();
            var userContext = new Mock <IUserContext>();

            userContext.Setup(m => m.Id).Returns(CurrentUserId);
            userContext.Setup(m => m.GroupId).Returns(CurrentUserCurrentGroupId);
            mocks.Add(userContext);
            StrixPlatform.User = userContext.Object;

            var environment = new DefaultEnvironment();

            StrixPlatform.Environment = environment;

            var dependencyInjectorMock = new Mock <IDependencyInjector>();

            DependencyInjector.Injector = dependencyInjectorMock.Object;
            dependencyInjectorMock.Setup(d => d.TryGet <IMembershipService>()).Returns((IMembershipService)null);
            mocks.Add(dependencyInjectorMock);

            var entityHelper = new Mock <IEntityHelper>();

            EntityHelper.SetHelper(entityHelper.Object);
            mocks.Add(entityHelper);

            var platformHelperMock = new Mock <IPlatformHelper>();

            mocks.Add(platformHelperMock);
            StrixCms.SetHelper(platformHelperMock.Object);

            return(mocks);
        }
示例#2
0
        public void GetManagerActionRecordsShouldReturnCorrectNumberOfRecords()
        {
            var mock = new EntityServiceManagerMock();
            var platformHelperMock = _mocks.First(m => m.GetType().Equals(typeof(Mock <IPlatformHelper>))) as Mock <IPlatformHelper>;
            var entityHelperMock   = _mocks.First(m => m.GetType().Equals(typeof(Mock <IEntityHelper>))) as Mock <IEntityHelper>;

            StrixCms.SetHelper(new DefaultPlatformHelper(null));
            var entityHelper = new DefaultEntityHelper(entityTypes);

            EntityHelper.SetHelper(entityHelper);
            var result = mock.EntityServiceManager.GetManagerActionRecords();

            StrixCms.SetHelper(platformHelperMock.Object);
            EntityHelper.SetHelper(entityHelperMock.Object);
            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Count);
            Assert.AreEqual(10, result.First().Item3.Count);
        }