Exemplo n.º 1
0
 public LoggerTests()
 {
     _buildEngine = Substitute.For <IBuildEngine>();
     _sut         = new Logger(Substitute.ForPartsOf <TaskLoggingHelper>(_buildEngine, "SyncUnicorn"));
 }
Exemplo n.º 2
0
 public void GivenTheElevatorIsOnTheFloor(int currentFloor)
 {
     elevator = Substitute.ForPartsOf <ElevatorBox>();
     elevator.CurrentFloor = currentFloor;
 }
 public ValidatedControllerTests()
 {
     service    = Substitute.For <IService>();
     validator  = Substitute.For <IValidator>();
     controller = Substitute.ForPartsOf <ValidatedControllerProxy>(validator, service);
 }
Exemplo n.º 4
0
        public void Logger()
        {
            var job = Substitute.ForPartsOf <BackgroundJob <string> >();

            job.Logger.ShouldBe(NullLogger <BackgroundJob <string> > .Instance);
        }
 public NodeDataBuilderTest()
 {
     builder = Substitute.ForPartsOf <NodeDataBuilder>(nodeData, fieldWrapper, parseMap);
 }
Exemplo n.º 6
0
 public GalleryManagerTests()
 {
     _fileManager    = Substitute.For <IFileManager>();
     _galleryManager = Substitute.ForPartsOf <GalleryManager>(_fileManager);
     _galleryManager.WhenForAnyArgs(x => x.CheckIfTargetDirExist(default)).DoNotCallBase();
Exemplo n.º 7
0
        public void ReturnDefaultForUnimplementedAbstractMethod()
        {
            var testAbstractClass = Substitute.ForPartsOf <TestAbstractClass>();

            Assert.AreEqual(default(int), testAbstractClass.AbstractMethodReturnsSameInt(1));
        }
Exemplo n.º 8
0
        public void OnAuthorization_IsAuthorized_SetsNullResult()
        {
            AuthorizationContext context = new AuthorizationContext(controller.ControllerContext, Substitute.ForPartsOf <ActionDescriptor>());

            Authorization.Provider.IsAuthorizedFor(controller.CurrentAccountId, "Area", "Controller", "Action").Returns(true);
            controller.ControllerContext.HttpContext.User.Identity.IsAuthenticated.Returns(true);
            context.RouteData.Values["controller"] = "Controller";
            context.RouteData.Values["action"]     = "Action";
            context.RouteData.Values["area"]       = "Area";

            ((IAuthorizationFilter)controller).OnAuthorization(context);

            Assert.Null(context.Result);
        }
Exemplo n.º 9
0
 public void CanNotCreatePartialSubForInterface()
 {
     Assert.Throws <CanNotPartiallySubForInterfaceOrDelegateException>(() => Substitute.ForPartsOf <ITestInterface>());
 }
Exemplo n.º 10
0
 public void CanNotCreatePartialSubForEventHander()
 {
     Assert.Throws <CanNotPartiallySubForInterfaceOrDelegateException>(() => Substitute.ForPartsOf <EventHandler>());
 }
Exemplo n.º 11
0
 public GeneratedSubscriptionControllerFacts()
 {
     _sut = Substitute.ForPartsOf <SubscriptionController>();
 }
Exemplo n.º 12
0
 public void BeforeEach()
 {
     _photonClient = Substitute.ForPartsOf <LoadBalancingClient>("", "", "", ConnectionProtocol.Udp);
     _photonClient.When(p => p.ConnectToRegionMaster(Arg.Any <string>())).DoNotCallBase();
 }
Exemplo n.º 13
0
 public BaseServiceTests()
 {
     unitOfWork = Substitute.For <IUnitOfWork>();
     service    = Substitute.ForPartsOf <BaseService>(unitOfWork);
 }
Exemplo n.º 14
0
 public void SetUp()
 {
     modifier = Substitute.ForPartsOf <SubGroupSelectionModifier.Modifier>();
 }
Exemplo n.º 15
0
        public void AddSpecialEmployeesTest()
        {
            var SpecialEmployees = new List <EmployeeDefinition>
            {
                new EmployeeDefinition()
                {
                    SpawnWhenAllConditionsAreMet = true,
                    GameProgress = 10,
                    NumberOfDaysTillEmpCanSpawn = 0,
                    MissionSucceeded            = new MissionDefinition[0],
                    ItemsBought = new ItemDefinition[0],
                    Recurring   = true
                },
                new EmployeeDefinition()
                {
                    SpawnWhenAllConditionsAreMet = true,
                    GameProgress = 0,
                    NumberOfDaysTillEmpCanSpawn = 0,
                    MissionSucceeded            = new MissionDefinition[0],
                    ItemsBought = new ItemDefinition[0],
                    Recurring   = true
                },
                new EmployeeDefinition()
                {
                    SpawnWhenAllConditionsAreMet = true,
                    GameProgress = 0,
                    NumberOfDaysTillEmpCanSpawn = 0,
                    MissionSucceeded            = new MissionDefinition[0],
                    ItemsBought = new ItemDefinition[0],
                    Recurring   = false
                },
                new EmployeeDefinition()
                {
                    SpawnWhenAllConditionsAreMet = true,
                    GameProgress = 0,
                    NumberOfDaysTillEmpCanSpawn = 0,
                    MissionSucceeded            = new MissionDefinition[0],
                    ItemsBought = new ItemDefinition[0],
                    Recurring   = true
                }
            };

            var contentHub = Substitute.For <ContentHub>();

            contentHub.DefaultSpecialEmployees = new EmployeeList()
            {
                employeeList = SpecialEmployees
            };
            var empManager = new EmployeeManager();

            Debug.LogWarning(empManager);
            empManager.InitDefaultState();
            empManager.data.employeesForHire.Add(new EmployeeData()
            {
                EmployeeDefinition = SpecialEmployees[0]
            });
            empManager.data.hiredEmployees.Add(new EmployeeData()
            {
                EmployeeDefinition = SpecialEmployees[1]
            });
            empManager.data.exEmplyoees.Add(new EmployeeData()
            {
                EmployeeDefinition = SpecialEmployees[2]
            });
            empManager.data.exEmplyoees.Add(new EmployeeData()
            {
                EmployeeDefinition = SpecialEmployees[3]
            });
            var factory = Substitute.ForPartsOf <EmployeeFactory>();

            factory.contentHub      = contentHub;
            factory.employeeManager = empManager;
            factory.ConditionsMet(new EmployeeDefinition()).ReturnsForAnyArgs(true);
            factory.AddSpecialEmployees();
            factory.ReceivedWithAnyArgs(4).ConditionsMet(Arg.Any <EmployeeDefinition>());
            Assert.AreEqual(1, factory.specialEmployeesToSpawn.Count);
            Assert.AreSame(SpecialEmployees[3], factory.specialEmployeesToSpawn[0]);
        }
Exemplo n.º 16
0
        public void OnAuthorization_NotAuthorized_RedirectsToUnauthorized()
        {
            controller.When(sub => sub.RedirectToUnauthorized()).DoNotCallBase();
            controller.ControllerContext.HttpContext.User.Identity.IsAuthenticated.Returns(true);
            controller.RedirectToUnauthorized().Returns(new RedirectToRouteResult(new RouteValueDictionary()));

            AuthorizationContext context = new AuthorizationContext(controller.ControllerContext, Substitute.ForPartsOf <ActionDescriptor>());

            ((IAuthorizationFilter)controller).OnAuthorization(context);

            ActionResult expected = controller.RedirectToUnauthorized();
            ActionResult actual   = context.Result;

            Assert.Equal(expected, actual);
        }
Exemplo n.º 17
0
        public PoaTestNode(string name,
                           IPrivateKey privateKey,
                           IPeerSettings nodeSettings,
                           IEnumerable <PeerId> knownPeerIds,
                           IFileSystem parentTestFileSystem,
                           ITestOutputHelper output)
        {
            Name          = name;
            _nodeSettings = nodeSettings;

            _nodeDirectory = parentTestFileSystem.GetCatalystDataDir().SubDirectoryInfo(Name);
            var nodeFileSystem = Substitute.ForPartsOf <FileSystem>();

            nodeFileSystem.GetCatalystDataDir().Returns(_nodeDirectory);

            _rpcSettings = RpcSettingsHelper.GetRpcServerSettings(nodeSettings.Port + 100);
            _nodePeerId  = nodeSettings.PeerId;

            var baseDfsFolder = Path.Combine(parentTestFileSystem.GetCatalystDataDir().FullName, "dfs");
            var hashProvider  = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            _dfs = new DevDfs(parentTestFileSystem, hashProvider, baseDfsFolder);

            _memPool        = new Mempool(new MempoolService(new InMemoryRepository <PublicEntryDao, string>()));
            _peerRepository = new PeerRepository(new InMemoryRepository <Peer, string>());
            var peersInRepo = knownPeerIds.Select(p => new Peer
            {
                PeerId = p
            }).ToList();

            _peerRepository.Add(peersInRepo);

            _containerProvider = new ContainerProvider(new[]
            {
                Constants.NetworkConfigFile(NetworkType.Devnet),
                Constants.SerilogJsonConfigFile
            }
                                                       .Select(f => Path.Combine(Constants.ConfigSubFolder, f)), parentTestFileSystem, output);

            Program.RegisterNodeDependencies(_containerProvider.ContainerBuilder,
                                             excludedModules: new List <Type>
            {
                typeof(ApiModule),
                typeof(RpcServerModule)
            }
                                             );
            _containerProvider.ConfigureContainerBuilder(true, true);
            OverrideContainerBuilderRegistrations();

            _scope = _containerProvider.Container.BeginLifetimeScope(Name);
            _node  = _scope.Resolve <ICatalystNode>();

            var keyStore    = _scope.Resolve <IKeyStore>();
            var keyRegistry = _scope.Resolve <IKeyRegistry>();

            keyRegistry.RemoveItemFromRegistry(KeyRegistryTypes.DefaultKey);
            keyRegistry.AddItemToRegistry(KeyRegistryTypes.DefaultKey, privateKey);

            keyStore.KeyStoreEncryptAsync(privateKey, nodeSettings.NetworkType, KeyRegistryTypes.DefaultKey)
            .ConfigureAwait(false).GetAwaiter()
            .GetResult();
        }
Exemplo n.º 18
0
 public void GivenTheElevatorIsOnTheGroundFloor()
 {
     elevator = Substitute.ForPartsOf <ElevatorBox>();
     elevator.CurrentFloor = 0;
 }
Exemplo n.º 19
0
 public BufferedNotificationStoreTests()
 {
     inMemoryCrudRepository = Substitute.ForPartsOf <InMemoryCrudRepository>();
     sut = new BufferedNotificationStore(inMemoryCrudRepository);
 }