Example #1
0
        public void reserve_lots_of_licenses()
        {
            var mother = new ObjectMother(_cut.GetApplicationSession());

            logSDKLicense();

            var licLog = Enumerable.Range(0, 14).Select(index =>
                {
                    var session = _cut.GetSession(mother.CreateEmployee().Login);
                    var lic = getSDKLicense();

                    return new LicLog
                        {
                            Remaining = lic.UserLicensesRemaining,
                            GraceRemaining = lic.GraceLicensesRemaining,
                            GraceEventsRemaining = lic.GraceEventsRemaining,
                            Session = session
                        };
                }).ToArray();

            licLog.Each(r=>Console.WriteLine(r.ToString()));

            foreach (var log in licLog)
            {
                _cut.EjectSession(log.Session.UserName);
                logSDKLicense();
            }
        }
Example #2
0
 public void SetUp()
 {
     _mother = new ObjectMother();
     _account = _mother.GetAccountByEmailAddress("*****@*****.**");
     _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();
     _areaRepository = MockRepository.GenerateMock<IRepository<Area>>();
     _mapGenerator = new MapGenerator();
     _controller = new GameController(_playerRepository, _areaRepository, _mapGenerator);
     _view = new CreatePlayerView
                      {
                          Name = "Dr. Evil",
                          BaseName = "My Base",
                          BaseLatitude = _latitude,
                          BaseLongitude = _longitude
                      };
 }
Example #3
0
        public void Arrange()
        {
            _login = new LoginModel {EmailAddress = _emailAddress, Password = _password};
            _mother = new ObjectMother();
            _account = _mother.GetAccountByEmailAddress(_emailAddress, _password);
            _currentPlayer = new Player
            {
                Account = _account,
                Name = "Player1"
            };

            _accountRepository = new InMemoryRepository<Account>(_account);
            _playerRepository = new InMemoryRepository<Player>(_currentPlayer);

            _formsService = MockRepository.GenerateMock<IFormsService>();

            _controller = new AccountController(_accountRepository, _playerRepository, _formsService);
        }
Example #4
0
 public void matches_with_no_rules_is_true()
 {
     new ErrorHandler().Matches(ObjectMother.Envelope(), new Exception())
     .ShouldBeTrue();
 }
Example #5
0
 public void NotaFiscal_Dominio_ValidarSeNaoFoiEmitida_Sucesso()
 {
     _notaFiscal             = ObjectMother.PegarNotaFiscalValida(_emitenteMock.Object, _destinatarioMock.Object, _transportadorMock.Object);
     _notaFiscal.ChaveAcesso = "";
     _notaFiscal.FoiEmitida.Should().BeFalse();
 }
Example #6
0
        public void Test_Evaluation_ValidateEvaluationNoResults_ShouldBeOk()
        {
            Evaluation evaluation = ObjectMother.GetNewValidEvaluationNoresults();

            evaluation.Validate();
        }
 public void Initialize()
 {
     _product = ObjectMother.GetProductOk();
 }
        public void Map()
        {
            // Arrange
            var start = new DateTime(2010, 1, 1);
            var end   = DateUtility.MaxDate;
            var range = new DateRange(start, end);

            var id = new EnergyTrading.Mdm.Contracts.MdmId {
                SystemName = "Test", Identifier = "A"
            };
            var contractDetails = new EnergyTrading.MDM.Contracts.Sample.BrokerDetails();
            var contract        = new EnergyTrading.MDM.Contracts.Sample.Broker
            {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList {
                    id
                },
                Details       = contractDetails,
                MdmSystemData = new EnergyTrading.Mdm.Contracts.SystemData {
                    StartDate = start, EndDate = end
                },
                Party = ObjectMother.Create <Party>().CreateNexusEntityId(() => "")
            };

            // NB Don't assign validity here, want to prove SUT sets it
            var details = new BrokerDetails();

            var mapping = new PartyRoleMapping();

            var mappingEngine = new Mock <IMappingEngine>();
            var repository    = new Mock <IRepository>();

            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(id)).Returns(mapping);
            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.BrokerDetails, BrokerDetails>(contractDetails)).Returns(details);
            repository.Setup(x => x.FindOne <Party>(int.Parse(contract.Party.Identifier.Identifier))).Returns(ObjectMother.Create <Party>());

            var mapper = new BrokerMapper(mappingEngine.Object, repository.Object);

            // Act
            var candidate = mapper.Map(contract);

            // Assert
            //Assert.AreEqual(1, candidate.Details.Count, "Detail count differs");
            Assert.AreEqual(1, candidate.Mappings.Count, "Mapping count differs");
            Assert.AreEqual("Broker", candidate.PartyRoleType);
            Check(range, details.Validity, "Validity differs");
        }
Example #9
0
 public void GetUser_Returns_Null_When_Token_Is_Valid_But_UserId_Does_Not_Match_Id_Retrieved()
 {
     Assert.IsNull(FacebookMarketingUserInfoClient.GetUser(ObjectMother.Create <string>(), Token));
 }
Example #10
0
 public void Infra_Concurso_SQLRepository_Deveria_Adicionar_Concurso()
 {
     _concurso = ObjectMother.GetConcurso();
     _concurso = _repository.Adicionar(_concurso);
     _concurso.Id.Should().BeGreaterThan(0);
 }
 public void LivroRepository_set()
 {
     _livroSqlRepository = new LivroSqlRepository();
     _livro = ObjectMother.Livro();
     BaseSqlTest.SeedDatabase();
 }
        protected override Location Default()
        {
            var entity = ObjectMother.Create <Location>();

            return(entity);
        }
 public void Retrieve_Throws_UserCredentialsException_When_Secret_Is_Not_A_Valid_FB_Token()
 {
     CreateSubjectUnderTest()
     .Retrieve(ObjectMother.Create <string>(), ObjectMother.Create <string>());
 }
 public void Retrieve_Throws_UserCredentialsException_When_Secret_Is_A_Valid_FB_Token_But_UserIdentifier_Does_Not_Match_FB_User_Id()
 {
     CreateSubjectUnderTest()
     .Retrieve(ObjectMother.Create <string>(), Token);
 }
Example #15
0
        public void AllocationService_Update_Invalid_Id_ShouldBeFail()
        {
            Allocation modelo = ObjectMother.GetAllocation(ObjectMother.GetEmployee(), ObjectMother.GetRoom());

            modelo.Id = 0;

            AllocationService service = new AllocationService(_mockRepository.Object);

            Action update = () => service.Update(modelo);

            update.Should().Throw <IdentifierUndefinedException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Example #16
0
        public void AllocationService_Add_ShouldBeFail()
        {
            Allocation modelo = ObjectMother.GetInvalidEndHourAllocation(ObjectMother.GetEmployee(), ObjectMother.GetRoom());

            AllocationService service = new AllocationService(_mockRepository.Object);

            Action comparison = () => service.Save(modelo);

            comparison.Should().Throw <AllocationEndHourEarlyThanStartException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Example #17
0
        public void AllocationService_Delete_ShouldBeOk()
        {
            Allocation modelo = ObjectMother.GetAllocation(ObjectMother.GetEmployee(), ObjectMother.GetRoom());

            modelo.Id = 1;

            _mockRepository.Setup(m => m.Delete(modelo));


            AllocationService service = new AllocationService(_mockRepository.Object);

            service.Delete(modelo);

            _mockRepository.Verify(repository => repository.Delete(modelo));
        }
Example #18
0
 public void Service_Aposta_Deveria_Gerar_Numeros_Da_Aposta_Automaticamente()
 {
     _aposta = ObjectMother.GetApostaSemNumerosApostados();
     _service.GerarApostaAutomaticamente(_aposta);
     _aposta.numerosApostados.Count.Should().Be(6);
 }
Example #19
0
        public void initialize()
        {
            _FakeAposta = new Mock <Aposta>();

            _dezena = ObjectMother.GetDezenas(_FakeAposta.Object);
        }
Example #20
0
 public void GetUser_Returns_Null_When_No_Data_Is_Retrieved_Because_Token_Is_Invalid()
 {
     Assert.IsNull(FacebookMarketingUserInfoClient
                   .GetUser(ObjectMother.Create <string>(), ObjectMother.Create <string>()));
 }
Example #21
0
        protected override Exchange Default()
        {
            var entity = ObjectMother.Create <Exchange>();

            return(entity);
        }
Example #22
0
 public void PostSql_Save_ShouldBeOk()
 {
     _post = ObjectMother.GetPost();
     _post = _repository.Save(_post);
     _post.Id.Should().BeGreaterThan(0);
 }
Example #23
0
 public void SetUp()
 {
     turma       = ObjectMother.ObterTurmaValida();
     repositorio = new Mock <ITurmaRepositorio>();
     servico     = new TurmaServico(repositorio.Object);
 }
 public void SetUp()
 {
     _ProdutoDefault = ObjectMother.ProdutoDefault();
 }
Example #25
0
 public void Integration_EditarConcurso_Incorretamente_Com_Hora_Menor_Que_Atual()
 {
     _concurso = ObjectMother.GetConcursoHoraMenorAtual();
     Action action = () => _service.Editar(_concurso);
     action.Should().Throw<InvalidDateTimeException>();
 }
 public void GetSettingAsDateTime_Throws_FormatException_When_Setting_Is_Not_A_Valid_DateTime_Representation()
 {
     GetSettingAsDateTime(ObjectMother.Create <string>());
 }
 public void SetUp()
 {
     var mother = new ObjectMother();
     _model = mother.GetValidAccount();
     _existingAccount = mother.GetAccountByEmailAddress(_model.EmailAddress);
     _newModel = mother.GetValidAccount();
     _newModel.EmailAddress = "*****@*****.**";
     _accountRepository = new InMemoryRepository<Account>(_existingAccount);
     _formsService = MockRepository.GenerateMock<IFormsService>();
     _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();
     _controller = new AccountController(_accountRepository, _playerRepository, _formsService);
 }
Example #28
0
 protected override void beforeEach()
 {
     _graph = ObjectMother.DiagnosticsGraph();
     Container.Configure(x => x.For <BehaviorGraph>().Use(() => _graph));
 }
 protected override AuthorizationCodeTokenDocument CreateDocument(string key, string clientId = null, string subjectId = null)
 {
     return(ObjectMother.CreateAuthorizationCodeTokenDocument(key, clientId, subjectId));
 }
Example #30
0
 protected override void beforeEach()
 {
     response = new SamlResponse {
         Certificates = new ICertificate[] { ObjectMother.Certificate1() }
     };
 }
Example #31
0
        public void ValidDetailsSaved()
        {
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            // Contract
            var cd    = new MDM.Contracts.CurveDetails();
            var nexus = new MDM.Contracts.SystemData {
                StartDate = new DateTime(2012, 1, 1)
            };
            var identifier = new MDM.Contracts.NexusId {
                SystemName = "Test", Identifier = "A"
            };
            var contract = new MDM.Contracts.Curve {
                Details = cd, Nexus = nexus
            };

            contract.Identifiers.Add(identifier);

            // Domain
            var system = new SourceSystem {
                Name = "Test"
            };
            var mapping = new CurveMapping {
                System = system, MappingValue = "A"
            };
            var d1 = ObjectMother.Create <Curve>();

            d1.Id        = 1;
            d1.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 };
            var entity = ObjectMother.Create <Curve>();

            entity.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 };
            entity.AddDetails(d1);

            var d2    = ObjectMother.Create <Curve>();
            var range = new DateRange(new DateTime(2012, 1, 1), DateTime.MaxValue);

            validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true);
            validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true);

            repository.Setup(x => x.FindOne <Curve>(1)).Returns(entity);

            mappingEngine.Setup(x => x.Map <MDM.Contracts.CurveDetails, Curve>(cd)).Returns(d2);
            mappingEngine.Setup(x => x.Map <MDM.Contracts.SystemData, DateRange>(nexus)).Returns(range);
            mappingEngine.Setup(x => x.Map <MDM.Contracts.NexusId, CurveMapping>(identifier)).Returns(mapping);

            var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            // Act
            service.Update(1, 74, contract);

            // Assert
            Assert.AreEqual(0, d2.Mappings.Count, "Created entity mappings count differs");
            Assert.AreEqual(0, d2.Id, "Created entity id differs");

            Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs");
            repository.Verify(x => x.Save(entity));
            repository.Verify(x => x.Flush());

            // Ok, hack the created one to align it
            d2.Id = entity.Id;
            foreach (var m in entity.Mappings)
            {
                d2.Mappings.Add(m);
            }

            // Should now be the same - avoid exposing what properties we have here
            Check(d2, entity);
        }
 public void Should_validate_account_correctly()
 {
     var model = new ObjectMother().GetValidAccount();
     model.AssertValid();
     model.AssertErrorFor(m => m.EmailAddress, "notValid");
     model.AssertErrorFor(m => m.EmailAddress, null);
     model.AssertErrorFor(m => m.FirstName, null);
     model.AssertErrorFor(m => m.LastName, null);
     model.AssertErrorFor(m => m.ConfirmPassword, "nottherightpassword");
 }
 public void Exists_Returns_False_When_No_Entry_Exists_With_Specified_Key()
 {
     Assert.IsFalse(_sut.Exists(ObjectMother.Create <string>()));
 }
 public void Resultado_ServiceTests_AddResultado_ShouldBe()
 {
     Resultado resultadoToSave = ObjectMother.GetResultado();
 }
 public void ThrowIf_Throws_ValidationException_When_TestProperty_Is_Not_TestValue_And_RuleSet_Is_Rule()
 {
     ThrowIf(ObjectMother.Create <string>(), "Rule");
 }