Пример #1
0
        public void GivenIHaveGeneratedARandomRegistrationData()
        {
            var testDataGenerator = new TestDataGenerator();

            _registration = testDataGenerator.GetRegistrationData();
            Assert.IsNotNull(_registration);
        }
        public async Task Get_ShouldReturnNotFoundIfPropertyDoesNotExists()
        {
            var result = await _propertiesControllerMock.Get(9);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Пример #3
0
        public async Task GetAll_ShouldReturnListOfBrokerEntitiesType()
        {
            var result = await _brokerRepositoryMock.GetAll();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, _brokerListMock.GetType());
        }
Пример #4
0
        public void Add()
        {
            var tag = new ArticleTag()
            {
                Description  = "Test data",
                Name         = "Test",
                ModifiedById = null,
                CompanyId    = 1,
                Resources    = new List <ArticleTagResource>
                {
                    new ArticleTagResource {
                        Culture = Culture.English, Value = "Test"
                    },
                    new ArticleTagResource {
                        Culture = Culture.Spanish, Value = "Prueba"
                    },
                    new ArticleTagResource {
                        Culture = Culture.Hindi, Value = "pareekshan"
                    }
                }
            };
            var result = _tagService.Add(tag);

            Assert.IsNotNull(result);
        }
Пример #5
0
        public void IsHttpCreateStreamWorks()
        {
            var response = _httpProtocolDownlaoder.GetFileInfo(_resourceDetailhttp);

            Assert.IsFalse(false);
            Assert.IsNotNull(response.ReturnedValue);
        }
        public void TestAlienShieldCollisionExplosion()
        {
            // Given
            var game = Match.GetInstance();

            game.StartNewGame();
            var map = game.Map;


            var shields = new List <Shield>
            {
                (Shield)map.GetEntity(map.Width - 4, map.Height - 5),
                (Shield)map.GetEntity(map.Width - 4, map.Height - 6),
                (Shield)map.GetEntity(map.Width - 5, map.Height - 5),
                (Shield)map.GetEntity(map.Width - 5, map.Height - 6)
            };

            // When
            game.GetPlayer(2).AlienManager.TestMakeAllAliensMoveForward();
            game.GetPlayer(2).AlienManager.TestPreventAllAliensShoot();
            for (var i = 0; i < 6; i++)
            {
                game.Update();
            }

            // Then
            foreach (var shield in shields)
            {
                Assert.IsNotNull(shield, "Starting shield is missing.");
                var entity = map.GetEntity(shield.X, shield.Y);
                Assert.IsNull(entity, "Shield should have been destroyed, but wasn't.");
            }
        }
Пример #7
0
        public void SerializationTests_TypeWithInternalNestedClass()
        {
            var v = new MyTypeWithAnInternalTypeField();

            Assert.IsNotNull(SerializationManager.GetSerializer(typeof(MyTypeWithAnInternalTypeField)));
            Assert.IsNotNull(SerializationManager.GetSerializer(typeof(MyTypeWithAnInternalTypeField.MyInternalDependency)));
        }
        public async Task Get_ShouldReturnPropertyIfPropertyExists()
        {
            var result = await _propertyRepositoryMock.Get(1);

            Assert.IsNotNull(result);
            Assert.AreEqual(result, _propertyListMock.ElementAt(0));
        }
Пример #9
0
        public void GenerateSlug_WithValidDataAndOtherSlugSeparator_ShouldReturnSlugString(string text)
        {
            var slug = text.GenerateSlug("_");

            Assert.IsNotNull(slug);
            Console.WriteLine(slug);
        }
        public void AzureTableStore_ConvertToFromStorageFormat_GrainReference_List()
        {
            // NOTE: This test requires Silo to be running & Client init so that grain references can be resolved before serialization.
            Guid[]  ids    = { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            IUser[] grains = new IUser[3];
            grains[0] = GrainClient.GrainFactory.GetGrain <IUser>(ids[0]);
            grains[1] = GrainClient.GrainFactory.GetGrain <IUser>(ids[1]);
            grains[2] = GrainClient.GrainFactory.GetGrain <IUser>(ids[2]);

            var initialState = new GrainStateContainingGrainReferences();

            foreach (var g in grains)
            {
                initialState.GrainList.Add(g);
                initialState.GrainDict.Add(g.GetPrimaryKey().ToString(), g);
            }
            var entity  = new DynamicTableEntity();
            var storage = new AzureTableStorage();

            storage.InitLogger(logger);
            storage.ConvertToStorageFormat(initialState, entity);
            var convertedState = (GrainStateContainingGrainReferences)storage.ConvertFromStorageFormat(entity);

            Assert.IsNotNull(convertedState, "Converted state");
            Assert.AreEqual(initialState.GrainList.Count, convertedState.GrainList.Count, "GrainList size");
            Assert.AreEqual(initialState.GrainDict.Count, convertedState.GrainDict.Count, "GrainDict size");
            for (int i = 0; i < grains.Length; i++)
            {
                string iStr = ids[i].ToString();
                Assert.AreEqual(initialState.GrainList[i], convertedState.GrainList[i], "GrainList #{0}", i);
                Assert.AreEqual(initialState.GrainDict[iStr], convertedState.GrainDict[iStr], "GrainDict #{0}", i);
            }
            Assert.AreEqual(initialState.Grain, convertedState.Grain, "Grain");
        }
        public async Task GetAll_ShouldReturnListOfPropertyEntitiesType()
        {
            var result = await _propertyRepositoryMock.GetAll();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, _propertyListMock.GetType());
        }
Пример #12
0
        public void GetMethodTest()
        {
            var b = ClassAdapter <A, B> .Adapt(new A { X = 100, Y = 50 });

            Assert.IsNotNull(b);
            Assert.IsTrue(b.Total == 150);
        }
        public void Get2GrainsFromCache()
        {
            int      size   = 2;
            TimeSpan maxAge = TimeSpan.MaxValue;

            var cache = new GrainReferenceCache <int, ISimpleGrain>(size, maxAge,
                                                                    GrainCreatorFunc,
                                                                    r => r.AsReference <ISimpleGrain>());

            int id1    = 1;
            var grain1 = cache.Get(id1);

            Assert.IsNotNull(grain1);
            //Assert.AreEqual(id1, grain1.A.Result);

            Assert.AreEqual(1, cache.Count);
            Assert.AreEqual(1, numGrainsCreated);

            int id2    = 2;
            var grain2 = cache.Get(id2);

            Assert.IsNotNull(grain2);
            //Assert.AreEqual(id2, grain2.A.Result);

            Assert.AreEqual(2, cache.Count);
            Assert.AreEqual(2, numGrainsCreated);

            //Assert.AreEqual(id1, grain1.A.Result);
        }
Пример #14
0
        public void Add()
        {
            var newCategory = new ArticleCategory
            {
                Name         = "Test",
                Description  = "",
                ModifiedById = null,
                CompanyId    = 1,
                Resources    = new List <ArticleCategoryResource>
                {
                    new ArticleCategoryResource {
                        Culture = Culture.English, Value = "Test"
                    },
                    new ArticleCategoryResource {
                        Culture = Culture.Spanish, Value = "Prueba"
                    },
                    new ArticleCategoryResource {
                        Culture = Culture.Hindi, Value = "pareekshan"
                    }
                }
            };
            var result = _categoryService.Add(newCategory);

            Assert.IsNotNull(result);
        }
Пример #15
0
        public void Index()
        {
            var controller = new HomeController(sendJobOffersServiceMock.Object);
            var result     = controller.Index() as ViewResult;

            Assert.IsNotNull(result);
        }
Пример #16
0
        public void ObjectFill()
        {
            var obj = this._fixture.Create <DummyObject>();

            Assert.IsNotNull(obj.Property1);
            Assert.IsNotNull(obj.Property2);
        }
        public void TestAlienSpawnLeftWithWavesLeft()
        {
            // Given
            var game = Match.GetInstance();

            game.StartNewGame();
            var map    = game.Map;
            var aliens = game.GetPlayer(1).AlienManager;

            // When
            while (aliens.Waves.Count < 2)
            {
                game.Update();
            }

            while (aliens.DeltaX < 0)
            {
                game.Update();
            }

            foreach (var alien in aliens.Waves[1])
            {
                alien.Destroy();
            }
            game.Update();

            var leftAlien = map.GetEntity(2, map.Height / 2 - 1);

            // x = 2 due to alien spawning and moving in the same update

            // Then
            Assert.IsNotNull(leftAlien, "Alien did not spawn on the left edge of the map as expected.");
        }
        public void GetHosts()
        {
            Dictionary <SiloAddress, SiloStatus> siloStatuses = mgmtGrain.GetHosts(true).Result;

            Assert.IsNotNull(siloStatuses, "Got some silo statuses");
            Assert.AreEqual(2, siloStatuses.Count, "Number of silo statuses");
        }
        public async Task AzureTableStorage_ConvertToFromStorageFormat(int?stringLength, string useJson)
        {
            var testName = string.Format("{0}({1} = {2}, {3} = {4})",
                                         nameof(AzureTableStorage_ConvertToFromStorageFormat),
                                         nameof(stringLength), stringLength == null ? "default" : stringLength.ToString(),
                                         nameof(useJson), useJson);

            var storage = await InitAzureTableStorageProvider(useJson, testName);

            var logger = LogManager.GetLogger("PersistenceProviderTests");

            storage.InitLogger(logger);

            var initialState = TestStoreGrainState.NewRandomState(stringLength).State;
            var entity       = new DynamicTableEntity();

            storage.ConvertToStorageFormat(initialState, entity);

            var convertedState = (TestStoreGrainState)storage.ConvertFromStorageFormat(entity);

            Assert.IsNotNull(convertedState, "Converted state");
            Assert.AreEqual(initialState.A, convertedState.A, "A");
            Assert.AreEqual(initialState.B, convertedState.B, "B");
            Assert.AreEqual(initialState.C, convertedState.C, "C");
        }
Пример #20
0
        public void TestCannotHaveTwoCopiesOfSameBuildingMissileController()
        {
            // Given
            var game = Match.GetInstance();

            game.StartNewGame(true);

            var map  = game.Map;
            var ship = game.GetPlayer(1).Ship;

            // When
            ship.Command = ShipCommand.BuildMissileController;
            game.Update();
            var building = map.GetEntity(ship.X, ship.Y + 1);

            for (var i = 0; i < 4; i++)
            {
                ship.Command = ShipCommand.MoveLeft;
                game.Update();
            }

            ship.Command = ShipCommand.BuildMissileController;
            game.Update();
            var noBuilding = map.GetEntity(ship.X, ship.Y + 1);

            // Then
            Assert.IsNotNull(building, "The building was not built.");
            Assert.IsNull(noBuilding,
                          "The game incorrectly allowed the player to build a second copy of the same building.");
        }
Пример #21
0
        public void NotNullQuery_True()
        {
            var query = _fixture.Create <SqlIssueMeetingRepository>();
            var res   = query.GetIssueQueryResults();

            Assert.IsNotNull(res);
        }
Пример #22
0
        public async Task ActivationSched_WhenAny_Timeout()
        {
            TaskScheduler scheduler = masterScheduler.GetWorkItemGroup(context).TaskRunner;

            ManualResetEvent pause1 = new ManualResetEvent(false);
            ManualResetEvent pause2 = new ManualResetEvent(false);
            var        finish       = new TaskCompletionSource <bool>();
            Task <int> task1        = null;
            Task <int> task2        = null;
            Task       join         = null;
            Task       wrapper      = new Task(() =>
            {
                task1 = Task <int> .Factory.StartNew(() =>
                {
                    output.WriteLine("Task-1 Started");
                    Assert.AreEqual(scheduler, TaskScheduler.Current, "TaskScheduler.Current=" + TaskScheduler.Current);
                    pause1.WaitOne();
                    output.WriteLine("Task-1 Done");
                    return(1);
                });
                task2 = Task <int> .Factory.StartNew(() =>
                {
                    output.WriteLine("Task-2 Started");
                    Assert.AreEqual(scheduler, TaskScheduler.Current, "TaskScheduler.Current=" + TaskScheduler.Current);
                    pause2.WaitOne();
                    output.WriteLine("Task-2 Done");
                    return(2);
                });

                join = Task.WhenAny(task1, task2, Task.Delay(TimeSpan.FromSeconds(2)));

                finish.SetResult(true);
            });

            wrapper.Start(scheduler);

            var timeoutLimit = TimeSpan.FromSeconds(1);

            try
            {
                await finish.Task.WithTimeout(timeoutLimit);
            }
            catch (TimeoutException)
            {
                Assert.Fail("Result did not arrive before timeout " + timeoutLimit);
            }

            Assert.IsNotNull(join, "Joined promise assigned");
            await join;

            Assert.IsTrue(join.IsCompleted && !join.IsFaulted, "Join Status " + join.Status);
            Assert.IsFalse(task1.IsFaulted, "Task-1 Faulted " + task1.Exception);
            Assert.IsFalse(task1.IsCompleted, "Task-1 Status " + task1.Status);
            Assert.IsFalse(task2.IsFaulted, "Task-2 Faulted " + task2.Exception);
            Assert.IsFalse(task2.IsCompleted, "Task-2 Status " + task2.Status);
            pause1.Set();
            task1.Ignore();
            pause2.Set();
            task2.Ignore();
        }
Пример #23
0
        public async Task RuntimeCodeGenTest()
        {
            var grain    = GrainFactory.GetGrain <IRuntimeCodeGenGrain <@event> >(Guid.NewGuid());
            var expected = new @event
            {
                Id  = Guid.NewGuid(),
                @if = new List <@event> {
                    new @event {
                        Id = Guid.NewGuid()
                    }
                },
                PrivateId = Guid.NewGuid(),
                @public   = new @event {
                    Id = Guid.NewGuid()
                },
                Enum = @event.@enum.@int
            };

            var actual = await grain.SetState(expected);

            Assert.IsNotNull(actual, "Result of SetState should be a non-null value.");
            Assert.IsTrue(expected.Equals(actual));

            var newActual = await grain.@static();

            Assert.IsTrue(expected.Equals(newActual), "Result of @static() should be equal to expected value.");
        }
        public void HKS_3Key_Read_Write()
        {
            string testName = Guid.NewGuid().ToString(); //TestContext.TestName;

            int key1 = _keyCounter++;
            int key2 = _keyCounter++;
            int key3 = _keyCounter++;

            var keys = new[]
            {
                Tuple.Create(KeyName1, key1.ToString(CultureInfo.InvariantCulture)),
                Tuple.Create(KeyName2, key2.ToString(CultureInfo.InvariantCulture)),
                Tuple.Create(KeyName3, key3.ToString(CultureInfo.InvariantCulture))
            }.ToList();

            var data = new Dictionary <string, object>();

            data[ValueName1] = testName + 1;
            data[ValueName2] = testName + 2;
            data[ValueName3] = testName + 3;

            var store = new HierarchicalKeyStore(3);

            string eTag = store.WriteRow(keys, data, null);

            var result = store.ReadRow(keys);

            Assert.IsNotNull(result, "Null result");
            foreach (string valueName in data.Keys)
            {
                Assert.AreEqual(data[valueName], result[valueName], valueName);
            }
        }
        public async Task GetAll_ShouldNotReturnNull()
        {
            var result = await _propertiesControllerMock.Get() as OkNegotiatedContentResult <List <PropertyListItemDTO> >;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
        }
        public void HKS_Write2()
        {
            string testName = Guid.NewGuid().ToString(); //TestContext.TestName;

            int key1 = _keyCounter++;
            int key2 = _keyCounter++;

            List <Tuple <string, string> > keys = MakeKeys(key1, key2);

            var data = new Dictionary <string, object>();

            data[ValueName1] = testName;

            var store = new HierarchicalKeyStore(keys.Count);

            // Write #1
            string eTag = store.WriteRow(keys, data, null);

            data[ValueName1] = "One";
            data[ValueName2] = "Two";
            data[ValueName3] = "Three";

            // Write #2
            string newEtag = store.WriteRow(keys, data, eTag);

            var result = store.ReadRow(keys);

            Assert.IsNotNull(result, "Null result");
            foreach (string valueName in data.Keys)
            {
                Assert.AreEqual(data[valueName], result[valueName], valueName);
            }
        }
Пример #27
0
        public void LoginPost_Test()
        {
            // Arrange
            HttpContextBase   context    = FakeHttpContext();
            AccountController controller = new AccountController(_accountService, _encryptService, _formsAuthenticationService);

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);
            var requestContext = new RequestContext(context, new RouteData());

            controller.Url = new UrlHelper(requestContext);

            var model = new EmployeeModel
            {
                Email         = "fake login",
                PasswordClear = "fake password",
                AutoLogon     = true
            };
            var returnUrl = "/employee/List/2";

            // Act
            var result = controller.Login(model, returnUrl) as RedirectResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(returnUrl, result.Url);
        }
        public async Task Get_ShouldReturnBrokerDTOIfBrokerExists()
        {
            var result = await _brokerServiceMock.Get(1);

            Assert.IsNotNull(result);
            Assert.IsTrue(CompareBrokerDTO(result, _brokerListDtoMock.ElementAt(0)));
        }
Пример #29
0
        public async Task Get_ShouldReturnBrokerIfBrokerExists()
        {
            var result = await _brokerRepositoryMock.Get(1);

            Assert.IsNotNull(result);
            Assert.AreEqual(result, _brokerListMock.ElementAt(0));
        }
Пример #30
0
        public void Create_WhenCreateStockFailed()
        {
            //Arrange
            var stockData = new StockData
            {
                Name       = "Apple",
                Price      = 2,
                Percentage = 3,
                Quantity   = 200,
                Years      = 10
            };

            _stockRespositoryMock.Setup(g => g.Create(stockData)).Returns(false);

            //Act
            ServiceResult <StockData> result = _stockService.Create(stockData);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(result.Succeeded);
            Assert.IsNull(result.Result);
            Assert.IsNotNull(result.Errors);
            _stockRespositoryMock.Verify(g => g.Create(It.IsAny <StockData[]>()), Times.Once);
            _calculationServiceMock.Verify(g => g.Create(It.IsAny <Calculation[]>()), Times.Never);
        }