Пример #1
0
        public void SaveDTOobject_FileExist_AddToFile()
        {
            _stubRemoteFile.Stub(x => x
              .ReadFileData(Path))
              .Return(StringToDesirialize);

             _stubDtoPlayer = new PlayerDTO()
             {
                 Name = "",
                 Age = 0,
                 Amplua = "",
                 Height = 0,
                 Number = 0,
                 Mail = "",
                 PhoneNumber = ""
             };

             _stubPlayer = new Player()
             {
                 Name = _stubDtoPlayer.Name,
                 Age = _stubDtoPlayer.Age,
                 Amplua = _stubDtoPlayer.Amplua,
                 Height = _stubDtoPlayer.Height,
                 Number = _stubDtoPlayer.Number,
                 Mail = _stubDtoPlayer.Mail,
                 PhoneNumber = _stubDtoPlayer.PhoneNumber
             };

             _stubSerializer.Stub(x => x
                .DeSerialize<List<Player>>(StringToDesirialize))
                .Return(_playerList);

             _playerList.Add(_stubPlayer);

             _stubSerializer.Stub(x => x
                   .Serialize(Arg<List<Player>>.Matches(actualPlayers =>
                       CheckPlayers(actualPlayers, _playerList))))
                 .Return(SERIALIZEDSTRING_PLAYER_LIST);

             _target.SaveDTOobject(_stubDtoPlayer, Path);

             _stubRemoteFile.AssertWasCalled(x => x
                 .WriteFileData(Path, SERIALIZEDSTRING_PLAYER_LIST));
        }
Пример #2
0
        public void SaveDTOobject_FileIsEmptySaveInNew()
        {
            _stubRemoteFile.Stub(x => x
              .ReadFileData(Path))
              .Return(FILE_EMPTY_LIST_STRING);

             _stubDtoPlayer = new PlayerDTO()
             {
                 Name = "",
                 Age = 0,
                 Amplua = "",
                 Height = 0,
                 Number = 0,
                 Mail = "",
                 PhoneNumber = ""
             };
             var expectedPlayersList = new List<Player>();
             _stubPlayer = new Player()
             {
                 Name = _stubDtoPlayer.Name,
                 Age = _stubDtoPlayer.Age,
                 Amplua = _stubDtoPlayer.Amplua,
                 Height = _stubDtoPlayer.Height,
                 Number = _stubDtoPlayer.Number,
                 Mail = _stubDtoPlayer.Mail,
                 PhoneNumber = _stubDtoPlayer.PhoneNumber
             };
              expectedPlayersList.Add(_stubPlayer);

             _stubSerializer.Stub(x => x
                 .Serialize(Arg<List<Player>>.Matches(actualPlayers =>
                     CheckPlayers(actualPlayers, expectedPlayersList))))
               .Return(SERIALIZEDSTRING_PLAYER_LIST);

              _target.SaveDTOobject(_stubDtoPlayer,Path);

             //In this case is same
              _stubRemoteFile.AssertWasCalled(x => x
                  .WriteFileData(Path, SERIALIZEDSTRING_PLAYER_LIST));
             //_stubRemoteFile.AssertWasCalled(x => x
             //     .WriteFileData(Arg<string>.Is.Equal(PLAYER_JSON_FILE_P_ATH),
             //     Arg<string>.Is.Equal(SERIALIZEDSTRING_PLAYER_LIST)));
        }
Пример #3
0
        public void InIt()
        {
            _id = Guid.NewGuid();
            _stubModel = MockRepository.GenerateStub<IModel>();
            _stubTeamPlayers = MockRepository.GenerateStub<TeamPlayers>();
            _stubDtoPlayer = MockRepository.GenerateStub<PlayerDTO>();
            _stubPlayer = MockRepository.GenerateStub<Player>();

            _stubSerializer = MockRepository.GenerateStub<ISerializer>();
            _stubLinqService = MockRepository.GenerateStub<ILinqService>();
            _stubRemoteFile = MockRepository.GenerateStub<IRemoteFile>();
            _stubPersistentService = MockRepository.GenerateStub<IPersistentService>();
            _target = new PersistentService(_stubSerializer,
                _stubLinqService,_stubRemoteFile);
        }